如何检测$ result是mysql_fetch_array($ result)中有效的MySQL结果资源

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?

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

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

Or you could just do:

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