note 44401 rejected from function.mysql-num-rows by vincent
| From: | vincent@php.net | Date: | Wed, 04 Aug 2004 19:11:21 +0000 |
| Subject: | note 44401 rejected from function.mysql-num-rows by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73949@lists.php.net to get a copy of this message | ||
Note Submitter: jeremy@w00dy.net
----
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