SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert Query Problem

    Hi all,

    Why do I get this error...
    "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1"

    Here's my code...
    PHP Code:
     while($row mysql_fetch_array($result))
     {
           
    $class $row['class_ID'];
           
    $query "INSERT INTO training ".
                              
    "VALUES(NULL, '$class', '$ffnumber', NOW())";
          echo 
    $query;            
     }
     
    $result mysql_query($result) or die(mysql_error()); 
    Thanks

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Happy new year Kev!
    It's because one of you variables is incorrectly defined.What do you get when you echo the query?

    Mike

  3. #3
    SitePoint Enthusiast shn's Avatar
    Join Date
    Jan 2006
    Location
    Munich DE
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there!

    PHP Code:
    $result mysql_query($result) or die(mysql_error()); 
    I guess, you want to query $query, not $result.

    Patrick

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by shn
    Hi there!

    PHP Code:
    $result mysql_query($result) or die(mysql_error()); 
    I guess, you want to query $query, not $result.

    Patrick
    Good spot Patrick

  5. #5
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup. Cheers Patrick!


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
  •