tags:

views:

83

answers:

2

It's written in PHP,

and sometimes when I restart mysql,

will report:

Debug Warning:line 24 - mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Is there any way to detect if $result is a valid MySQL result resource?

+5  A: 

it'll be false if there's an error.

if ($result) {
    $row = mysql_fetch_array($result);
} else {
    echo "MySQL error: " . mysql_error();
}
nickf
A: 

Or you could just do:

if ($result) {
      $row = mysql_fetch_array($result);
      // Do everything you need to in here
 }
Jason