note 19801 deleted from function.mysql-num-rows by didou
| From: | didou@php.net | Date: | Thu, 19 Jun 2003 08:39:50 +0000 |
| Subject: | note 19801 deleted from function.mysql-num-rows by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50624@lists.php.net to get a copy of this message | ||
Note Submitter: stefan@gadhra.com
----
Found this rather interesting, though it may be common knowledge:
$sql = "select * from table where id=104";
$res = mysql_query($sql) or die (mysql_error().$sql);
$num = mysql_num_rows($res) or die (mysql_error().$sql);
if the number of rows returned was 0, $num dies and kicks the die error (mine just repeats out the
$sql variable), which has its uses. If you want to continue in the script, use:
$num = mysql_num_rows($res);
instead and it will return 0.