Page 1 of 1

SQL Table into PHP

Posted: Sun Apr 01, 2012 10:16 pm
by mtsgill
This is what I am getting as an error when running my php script where I am using SQL table.

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\index.php on line 26

My line 26 is:

while($row = mysql_fetch_array($result))

Please help!!

Re: SQL Table into PHP

Posted: Sun Apr 01, 2012 10:57 pm
by califdon
That message (which is a Warning, different from an Error) means that when it tries to fetch a row from your SQL result, instead of finding data, it found a boolean (true/false). This always means that your query failed, thus instead of a data resource, it just has the boolean value FALSE. So that means that your problem is in your SQL statement. In order to determine what that error is, you need to add an or die(mysql_error()) to your mysql_query() statement. Then you will receive a mysql error message, which should point directly at the cause of the query failure.