Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
I am getting this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/valerie2/public_html/elinkswap/snorris/filename.php on line 89
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/valerie2/public_html/elinkswap/snorris/filename.php on line 90
Here are the lines of code it is talking about:
dbConnect();
$SQL="SELECT fileID FROM uploads WHERE fileName='".$result."'";
//echo $SQL;
$rs=mysql_query($SQL);
echo mysql_num_rows($rs); // line 89
if(mysql_num_rows($rs)!=0){ // line 90
$extension=strrchr($result,'.');
$result=str_replace($extension,time(),$result);
$result=$result.$extension;
}
return $result;
}
Can someone explain to me why I keep getting this error?
This is because your
mysql_queryhas failed because of syntax or execution errors in the SQL command.Make sure you can execute your SQL query (the one that you get using
echo $SQL;line) in phpMyAdmin or whatever tool you have.Whenever
mysql_queryfails, it returnsFalseinstead of a mysql resource. So you should always checkif (!$rs)or use theor die(...)mechanism.