note 44401 added to function.mysql-num-rows
| From: | jeremy at w00dy dot net | Date: | Wed, 04 Aug 2004 19:10:21 +0000 |
| Subject: | note 44401 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73948@lists.php.net to get a copy of this message | ||
I have a login validation query as follows:
<?php
$searchquery = "SELECT * FROM
".$dbprefix."users WHERE
user = '".$_POST['user'].
"' AND pass = '".$encpass."' LIMIT
2";
$record = mysql_query($searchquery);
$num_results = mysql_num_rows($record);
?>
$num_results will always = 1 whether the query matched 0 or 1 rows. Therefore,
$_SESSION['id'] = mysql_result($record,0,"id");
will get an error if there are 0 matching rows.
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 6 in /var/login.php on line
XX
----
Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44401
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44401&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44401&report=yes
Search -- http://master.php.net/manage/user-notes.php