RE: mysql_num_rows
| From: | Roger Lewis | Date: | Wed, 18 Dec 2002 00:38:58 +0000 |
| Subject: | RE: mysql_num_rows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128622@lists.php.net to get a copy of this message | ||
I found the problem! It was a space before $ in ' $name' in line two of the
query.
Sorry for the trouble.
Roger
-----Original Message-----
From: Roger Lewis [mailto:re.lewis@attbi.com]
Sent: Tuesday, December 17, 2002 4:00 PM
To: Php-General
Subject: mysql_num_rows
Would someone be kind enough to explain why I'm not getting the correct
result from the following query. If I select a valid member no. and name,
the following query should return 1 row. This is not the case, however. It
returns zero rows.
$sql = "SELECT * FROM users WHERE member_no = '$member_no' and
name = ' $name' ";
$result = mysql_query($sql) or die ("Cannot verify the member");
$rows = mysql_num_rows($result);
echo "rows = $rows<br>";
Furthermore when trying the following query where the table "users" contains
13 rows, the query returns only 12 rows.
$sql = "SELECT * FROM users";
$result = mysql_query($sql) or die ("Cannot verify the member");
$rows = mysql_num_rows($result);
echo "rows = $rows<br>";
Conclusion: mysql_num_rows seems to be returning one less row than exists.
Is this correct?
Thanks in advance
Roger Lewis