Re: mysql_num_rows always returns 1?
| From: | Eugene Mah | Date: | Tue, 18 Jun 2002 12:57:00 +0000 |
| Subject: | Re: mysql_num_rows always returns 1? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102687@lists.php.net to get a copy of this message | ||
At 13:00 18-06-02 +0100, Mark Colvin wrote:
The function below works when I pass in a valid username and password and returns '1'. When I pass a username and password that is not in the database it still returns '1'. I have put some echo statements in for debugging and the value of $numresult is always '1'. Does mysql_num_rows retain results in memory or something like that or am I completely going down the wrong road?that's because when 'select count(*)' = 0 when it finds no results. So you get a record returned to $result with a single line that tells you count(*) was 0. what you should probably do is instead of counting, check for a valid username/password returned by your query. if they're blank, then $user/$pass are either incorrect or not in your users table. or, as someone else suggested, check the value of count(*) rather than the number of lines returned by the query. Eugene -- ---------------------------------------------------------------------
Eugene Mah, M.Sc., DABR eugenem@ix.netcom.com Medical Physicist/Misplaced Canuck maheug@musc.edu Department of Radiology "For I am a Bear of Very LittleMedical University of South Carolina Brain, and long words Bother
Charleston, South Carolina me." Winnie the Poohhttp://home.netcom.com/~eugenem/ PGP KeyID = 0x1F9779FD, 0x319393F4
PGP keys available on request ICQ 3113529 O----------------------------------------------------------------------