Forum Moderators: coopster
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/www/juttuffi/questions/admin/answereditform.php on line 10
There is nothing in the database
$aid = (int)$_GET['aid'];
$query1 = mysql_query("SELECT * FROM tquestions WHERE aid='$aid'");
$query2 = mysql_query("SELECT * FROM tquestions WHERE aid='$aid'");
if (mysql_numrows($query1) == 0)
{
echo "There is nothing in the database";
}
else if (mysql_numrows($query2) == 0)
{
echo "There is nothing in the database";
}
else
{
//echo rows etc.
}
?>
I cant think why these mysql_num_rows() function isnt working can someone help? I would appreciate it an awful lot.
[edited by: bysonary at 11:32 pm (utc) on Feb. 13, 2007]
$query1 = mysql_query("SELECT * FROM tquestions WHERE aid='$aid'") or die([url=http://us3.php.net/manual/en/function.mysql-error.php]mysql_error[/url]());
$query2 = mysql_query("SELECT * FROM tquestions WHERE aid='$aid'") or die(mysql_error());
[url=http://us2.php.net/mysql_num_rows]mysql_num_rows[/url] NOT mysql_numrows. That will cause an error too. You may also want to validate your integer a little better than just casting it to an int. It would be much better if you actually checked to see if the string contains integers otherwise you may get unexpected results:
$pattern = "/^[1-9][0-9]*$/i";
if(!preg_match($pattern,$aid)) {
echo 'Invalid number!';
exit;
}
[edited by: eelixduppy at 11:39 pm (utc) on Feb. 13, 2007]
Unknown column 'aid' in 'where clause'
I'd go back and check that real quick. Maybe the case is off? Sometimes it's a simple spelling mistake ;)