Can some one tell me why this doesnt work I get this error
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/public_html/formgen/use/canhelp/canhelppg.php on line 21
For this code
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = 'DELETE FROM canhelp WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) >= `DateCanHelp`';
mysql_query($query);
$query="SELECT First_Name, Last_Name, Comments, DateCanHelp FROM canhelp ORDER BY Datecanhelp DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num==0) {
}else{
}
mysql_close();
$i=0;
while ($i < $num) {
$First_Name=mysql_result($result,$i,"First_Name");
$Last_Name=mysql_result($result,$i,"Last_Name");
$Comments=mysql_result($result,$i,"Comments");
$DateCanHelp=mysql_result($result,$i,"DateCanHelp");
echo "<b>$First_Name / $Last_Name</b><br>$Comments<br>$DateCanHelp<hr>";
$i++;
}
?>
While this code works fine
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = 'DELETE FROM Comments WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) >= `date`';
mysql_query($query);
$query="SELECT First_Name, Alias, Comment, Date FROM Comments ORDER BY Date DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num==0) {
}else{
}
mysql_close();
$i=0;
while ($i < $num) {
$First_Name=mysql_result($result,$i,"First_Name");
$Alias=mysql_result($result,$i,"Alias");
$Comments=mysql_result($result,$i,"Comment");
$Date=mysql_result($result,$i,"Date");
echo "<b>$First_Name / $Alias</b><br>$Comments<br>$Date<hr>";
$i++;
}
?>
I know it is something little Im missing just havent found it for 3 hours Ive been changing this and that still nothing same error. All I did was copied the second code and changed some field values to match another table in the database.