Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Wednesday, May 4, 2011

MySQL Error Checking in PHP

So often it seems that I am seeing someone struggling to find out what is wrong with their PHP script. They see the following error message:

Warning: mysql_fetch_assoc():

 supplied argument is not a valid MySQL result resource

 in /var/www/htdocs/somefile.php on line 18

and have no clue what this means. The line number has no bearing on where the real problem is, and there may be a whole cascade of these messages. Let's assume the code looks something like this: