Hey.
If the
mysql_query call fails, it will return FALSE instead of a MySQL resource.
Also, if the query doesn't return a result table
(like with INSERT or UPDATE queries), the call will return TRUE, rather then a MySQL resource.
The
mysql_fetch_array function only takes a MySQL resource object, so if you don't make sure the query result is a resource, you will get this warning.
Typically, you do something like:
-
$result = mysql_query($sql);
-
if($result) {
-
while($row = mysql_fetch_array($result)) {
-
// etc.
-
}
-
}
Or just
-
$result = mysql_query($sql) or die(mysql_error());
-
while($row = mysql_fetch_array($result)) {
-
// etc.
-
}