I want to start a new topic about error messages. There are sometimes error messages in PHP, where the text is misleading or not easily understandable.
So this post should help everyone who finds an error he/she cannot explain to check if there is already an easy solution present.
Please feel free to add to the list.
If there are a lot of replies, just use the search.
First error:
the infamous "MySQL mysql_fetch_row(): supplied argument is not a valid MySQL result resource" error
Full Message:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in code.php on line 4
Example code:
<?php $sql="SELECT * FROM table WHERE <:,.39iu59u"; $result=mysql_query($sql); $row=mysql_fetch_row($result); ?>
What it does not mean:
The error is not on line 4!
What it does mean:
The error happened earlier!
The SQL statement had an error in it ("SELECT * FROM table WHERE <:,.39iu59u" is broken).
Because of that, mysql_query($sql) did not return a result, but false.
And because of that, mysql_fetch_row($result); returns an error, because mysql_fetch_row(false) does not make sense.
How to remove the error?
Change the mysql query code above this line like this:
<?php $sql="SELECT * FROM table WHERE <:,.39iu59u"; $result=mysql_query($sql) Â Â or die(mysql_error()."<br>nSQL: $sql"); $row=mysql_fetch_row($result); ?>This will show the error where it happens.













