Invalid supplied argument error (MySQL and PHP)

If you are trying to perform a query with mysql and you get a message that resembles the following,

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /path/to/your/file.php on line 86

If this happens, you can get more information by using the following code (the second code block is the fix that displays more detailed error reporting).

Original Code with unclear error message.

$query = mysql_query("select ...",$resource_id);

Code with error reporting.

if($query = mysql_query("select ...",$resource_id))
{
     #> Do whatever your code is supposed to do.
}
else
{
     print(mysql_error());
}

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.