Jump to content

PHP error log question


oskom

Recommended Posts

Hello all,

I've got a recurring error in the log that reads "supplied argument is not a valid MySQL result resource in /usr/local/ftp/path/to/file/page.php on line 56". This error occurs on various pages and always in reference to iterations of...

while($row = mysql_fetch_array($result))

 

or...

 

$row = mysql_fetch_array($result)

I always get results from the mysql queries in question so why would this be an error?

 

Link to comment
Share on other sites

There are various queries, but here's an example that keeps coming up...

$result = mysql_query("SELECT * FROM calendars WHERE calendarID = ".$_REQUEST['calendarID']);
while($row = mysql_fetch_array($result)) { 
    //LOOP THROUGH DATA
}

Link to comment
Share on other sites

The error is saying that the table you selected, or even coloumn within the table is invalid. Check all your database information and tables..

 

$result = mysql_query("SELECT * FROM calendars WHERE calendarID = ".$_REQUEST['calendarID']);

 

to

 

$result = mysql_query("SELECT * FROM calendars WHERE calendarID = ".$_REQUEST['calendarID']."");

 

Link to comment
Share on other sites

The error means that your mysql_query() function calls are failing and returned a FALSE value instead of a result resource.

 

For each query, you will need to find out why it failed. If this is occurring randomly, then it would either mean that the mysql server is experiencing problems or that you are not validating and checking your data that is being put into the query.

 

It also means that your code is not checking if the mysql_query() failed and blindly continues executing instead of outputting a meaningful error message and stopping.

Link to comment
Share on other sites

Responding to revraz...I've always done that only because those ID's are just integers and not text strings. In looking at the other pages with errors, that does seem to be the common thread.

 

PFMaBiSmAd, would revraz's observation about the end quotes in the query result in any of what you mentioned?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.