Re: Problem With mysql_query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Welter wrote:
I have the following code and it doesn't behave properly but I can't find my
error. The code is designed to validate user login. When I pass in an
invalid email name to the checkLogin function it returns a result, not FALSE
as the documentation describes. I can SELECT * from the table being used and
read out all of the data so I know that the DB connection is valid and that
I can compose a valid query. I have looked and looked at this code and can
find no error, does anyone see an error here. When the check if (!$result)
fails i.e. even thought the email/password are not in the db a none zero
result is returned, the calls to mysql_fetch_assoc () return empty strings.
The only clue I may have is that when I call mysql_free_result($result) I
get a warning saying that $result is not a valid resource. I sure I'm doing
something stupid but I just can't see it. Any help would be great!

As the documentation states, mysql_query will return false when it encounters an error. Not finding any matching rows is not an error. Use mysql_num_rows to check if any matching rows were returned.

I would also recommend that you enable notices in your php.ini as your code will cause at least 2 notices to be generated, both of which would have given you a clue as to where the problem lies.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux