SQL Table into PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mtsgill
Forum Newbie
Posts: 6
Joined: Sat Mar 31, 2012 12:06 pm

SQL Table into PHP

Post 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!!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: SQL Table into PHP

Post 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.
Post Reply