-1

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

I get the following warning:

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given
in /home/content/97/9548797/html/test/index.php on line 355

Code:

$gresrow = mysql_fetch_row($gresult1); 
while( $row = mysql_fetch_row( $gresult1 ) ){ $GDs[] = $row[0]; }

How can I remove this warning message?

Community
  • 1
  • 1
user1799052
  • 21
  • 1
  • 3
  • 8

4 Answers4

2

I would print out a mysql_error() to see what the error message is.

echo mysql_error();

Personally, I think it helps to print the SQL query out, especially if dynamic variables are being added to it. That way you can read exactly what SQL is being generated and sent to MySQL.

$query = "SELECT id FROM users where parentid=$display";
echo $query;

By doing this it will allow you to check if $display is set..

Finally, I would highly recommend you avoid using the mysql_ functions as they are going to be deprecated soon.

ajtrichards
  • 28,323
  • 13
  • 90
  • 97
0

You probably have a MySQL error. Try putting or die(mysql_error()); behind your mysql_query()-line and tell us what the error message is!

Christian Lundahl
  • 1,912
  • 3
  • 17
  • 29
0

It's complaining because gresult1 is a boolean. The reason it's a boolean is because it was set to false when your previous call (almost certainly mysql_query) failed.

You need to fix that problem. Or at least detect it and not blindly use the return value, something like:

$gresult1 = mysql_query("some dodgy non-functional query");
if (!$gresult1) {
    # handle error elegantly, then return
}
# NOW you can use gresult1 safely.

One thing to look for, assuming your query in a comment elsewhere wasn't just a typo, is the use of $diplay. You may want to check that you didn't mean $display (with an "s") since a non-existant or malformed $diplay variable would almost certainly render the query unparsable, leading to the failure.

But, bottom line even if that's not the case, you need to figure out why the earlier call failed.

paxdiablo
  • 814,905
  • 225
  • 1,535
  • 1,899
0

Your variable $gresult1 seems to be a boolean value, but it must be a result from mysql_query().

I guess, mysql_query() returned FALSE. You should first check, whether your query succeeded.

Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188