RE: mysql_num_rows
| From: | Frank Miller | Date: | Tue, 19 Feb 2002 14:22:17 +0000 |
| Subject: | RE: mysql_num_rows | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85390@lists.php.net to get a copy of this message | ||
Thanks to everyone that replied. After trying solutions from everyone and still not getting it to work I finally figured out why my code:
$result = mysql_query($query,$connection) or die("Error in Query");
$num = mysql_num_rows($result);
if ($num == 0)
echo something;else
echo something else;was not working. I had that piece of code in a while ($row =
mysql_fetch_array($result)) loop. It seems that if there is nothing to get the condition inside the while loop is false so my code above was never being executed. Even when I tried printing out the contents of $num it would always be blank. The clue came when I deliberately changed the vale of $num right above my code above and it still didn't work.Thanks again to all who replied. It was a good chance to learn about isset(), empty() and other functions. Frank Frank Miller Computer Specialist and Webmaster Technology and Distance Education Texas A&M University-Texarkana 2600 North Robison Rd Texarkana, Texas 75501 Phone: 903-223-3156
Fax: 903-223-3139Office: 165