note 19801 added to function.mysql-num-rows

From: Date: Mon, 11 Mar 2002 16:53:39 +0000
Subject: note 19801 added to function.mysql-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-27629@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.mysql-num-rows.php http://master.php.net/manage/user-notes.php?action=edit+19801 http://master.php.net/manage/user-notes.php?action=delete+19801 http://master.php.net/manage/user-notes.php?action=reject+19801

« previous php.notes (#27629) next »