HELP!! mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Discussion in 'MySQL' started by iBBnet, May 17, 2009.

  1. #1
    I'm getting this error message on my browser, and have a hard time troubleshooting it.

    What's wrong? Hope someone here has advice/solution...

    mysql_fetch_array(): supplied argument is not a valid MySQL result resource... on line 216

    Here's the code from line 213 - line 229 so you can get an idea:
    
          else
          {
             $query = mysql_query( "SELECT * FROM ".$config["mysqlguestbooktable"]."".$order."WHERE `id` = '".make_query_safe( $_GET['id'] )."' LIMIT 1" );
             $post = mysql_fetch_array( $query, MYSQL_ASSOC );
             $title = "Guestbook admin area";
             $subtitle = "Edit post";
             $text = "</p><form action=\"".$_SERVER['PHP_SELF']."?action=finedit\" method=\"POST\"><p>\n";
             $text .= "<input type=\"hidden\" name=\"id\" value=\"".$post['id']."\" />\n";
             $text .= "Name:<br /><input type=\"text\" name=\"name\" size=\"20\" value=\"".$post['name']."\" /><br /><br />\n";
             $text .= "Email:<br /><input type=\"text\" name=\"email\" size=\"20\" value=\"".$post['email']."\" /><br /><br />\n";
             $text .= "Comments:<br /><textarea rows=\"5\" cols=\"20\" name=\"comments\">".$post['comments']."</textarea><br /><br />\n";
             $text .= "Date:<br /><input type=\"text\" name=\"date\" size=\"20\" value=\"".$post['date']."\" /><br /><br />\n";
             $text .= "IP:<br /><input type=\"text\" name=\"ip\" size=\"20\" value=\"".$post['ip']."\" /><br /><br />\n";
             $text .= "<input type=\"Submit\" value=\"Save Edit\" />\n";
             $text .= "</p></form><p>\n";
          }
       }
    Code (markup):
    Specifically, the code below is from line 216:

    $post = mysql_fetch_array( $query, MYSQL_ASSOC );
    Code (markup):
     
    iBBnet, May 17, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    It means that your query is not returning a valid resource.

    Change this:

    $query = mysql_query( "SELECT * FROM ".$config["mysqlguestbooktable"]."".$order."WHERE `id` = '".make_query_safe( $_GET['id'] )."' LIMIT 1" );

    to this to debug...

    if(!$query = mysql_query( "SELECT * FROM ".$config["mysqlguestbooktable"]."".$order."WHERE `id` = '".make_query_safe( $_GET['id'] )."' LIMIT 1" )){

    die(mysql_error());

    }
     
    jestep, May 18, 2009 IP