Page 1 of 1

simplest problem of mysql_num_rows()

Posted: Tue Oct 11, 2005 7:22 pm
by rajan
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Code: Select all

<body>
<?
$sql="select * from acinfo ";
$result=mysql_query($sql)or die(mysql_error());
$count1=mysql_num_rows($result)or die(mysql_error());
if($count1>1)
{
echo "hello";
}
else
{
echo "hi";
}
echo "final";
?>
Problem:
When there is no record in table acinfo, it doesn't give any result even it can not print "final". what is the problem.
how can it display 0 record. is it the problem with mysql?


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Oct 11, 2005 8:06 pm
by feyd
it is problem with your usage of die(). When mysql_num_rows() returns zero, the die is run, but there are no errors from MySQL to display.