Re: Problems with mysql_num-rows()
| From: | Doug Thompson | Date: | Mon, 01 Nov 2004 05:01:07 +0000 |
| Subject: | Re: Problems with mysql_num-rows() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-37095@lists.php.net to get a copy of this message | ||
The variables are not being expanded. As a minimum, you need to escape the single quotes.
$query = "SELECT * from user where name=\'$userid\' and pass=password(\'$password\')"
Alternatively, you can concatenate the expanded variables.
$query = "SELECT * from user where name='".$userid."' and pass=password('".$password."')"
Good luck,
Doug
Arne Essa Madsen wrote:
I have the following problem: This one does not work: $query = "SELECT * from user where name='$userid' and pass=password('$password')"; $result = mysql_query($query, $link); $num_rows = mysql_num_rows($result); I get this error message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\wamp\www\fs1812_new\authmain.php on line 18 This one works OK: $query = "SELECT * FROM user"; $result = mysql_query($query, $link); $num_rows = mysql_num_rows($result); What is wrong and how can I use mysql_num_rows when the query include "WHERE" A fast response will be very much appreciated. Arne Essa Madsen; arne@aem-engineering.dk