SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Whats wrong?

  1. #1
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i'm trying to insert some data into a database and it wont insert.

    bear in mind this is a basic thing...it will be all intergrated into one page...when its working!

    in form.php i have

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="form1" method="post" action="coasterfileprocess.php">
      <p> Name of Download: 
        <input type="text" name="name" size="40">
        <br>
        Short Description:<br>
        <textarea name="desc" cols="40" rows="10"></textarea>
        <br>
        Size: 
        <input type="size" name="size">
        <br>
        <input type="submit" name="Submit" value="Submit">
      </p>
      </form>
    </body>
    </html>
    then in formprocess.php i have

    [code]

    <?PHP
    MySQL_Connect("localhost","atomico_main","oblivion");
    MySQL_Select_db("atomico_coasterfile");
    MySQL_Query("INSERT INTO downloads SET Name='$name',Description='$desc',Size='$size',Count=0");
    if (mysql_query($sql)) {
    echo("<P>Download added</P>");
    } else {
    echo("<P>Error adding new download: " .
    mysql_error() .
    "</P>");
    }
    ?>

    then, when i go to the page and submit the form it gives the error

    Erro adding new download: no data in query

    or something along those lines

    pleeease help!

    Alex
    Nearly 7 years old!

  2. #2
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    MySQL_Query("INSERT INTO downloads SET Name='$name',Description='$desc',Size='$size',Count=0");
      if (mysql_query($sql)) {
    Code:
    Try this...
    $sql="INSERT INTO downloads SET Name='$name',Description='$desc',Size='$size',Count=0";
    if (mysql_query($sql)) {
    I think that is were the problem will be, sorry if i have muffed it...its been a long day

    Cheers

    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  3. #3
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe....

    Your mysql database and your scripts don't match because you use INSERT INTO downloads SET Name='$name',Description='$desc',Size='$size',Count=0

    you may try this :

    INSERT INTO downloads (Name,Description,Size) values('$name','$desc','$size)
    www.djklik.com
    daily indonesian news on your computer

  4. #4
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It makes very little difference which insert method you use. Personally i use SET fieldname=value, etc because if you have say 30 columns to put data in it is easier to keep track of..
    Unless i am missing something you said?
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  5. #5
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i feel soo stupid after looking at mad onions bit i had done wrong

    i'm very tired and haven't had much sleep

    i'll checdk if it works later
    Nearly 7 years old!

  6. #6
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe this is a typo but maybe not:

    You said:

    <form name="form1" method="post" action="coasterfileprocess.php">


    yet later on you specified the file as formprocess.php

    Is this just a typo?

  7. #7
    SitePoint Evangelist mad-onion's Avatar
    Join Date
    Aug 2000
    Location
    Land of the long white cloud
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alex: Dont feel stupid, mistakes are part of programming...i mean look at microsoft!

    Peter: It had to have been a type, he would not get the error if the form was not arriving at the script...i used to be a detective, in my last lifetime!.

    Cheers All
    SiteOptions >> Services :: Products :: Contact
    Developers of PHP, C++, Visual Basic, MySQL, and more!

  8. #8
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol,

    okay,..


    Good luck


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •