List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 17 2001 1:18am
Subject:Re: Strange Mysql behaviour
View as plain text  
At 8:49 PM -0400 6/16/01, William Wong wrote:
>Hi there,
>
>For some reason, this query doesn't work:
>
>PHP4> mysql_query("select * from user where username='myname' and passwd =
>password('mypass')");

Define "doesn't work".  Fails to return rows?  PHP generates an error message?

>
>WHILE this one does work:
>
>PHP4> mysql_query("select * from user where username='myname' and
>password('mypass')");
>
>Notice the lack of "passwd = " in the second version.

password('mypass') is a legal expression.  It returns a non-empty string,
which probably evaluates to true.  The statement is therefore equivalent
to:

select * from user where username='myname'



>
>Anyone know why this is happening?
>
>Regards,
>- Will
>
>OS: FreeBSD 4.3R
>PHP: 4.05
>MySQL: 3.23.38
>
>mysql> describe user;
>+----------+-------------+------+-----+---------+-------+
>| Field    | Type        | Null | Key | Default | Extra |
>+----------+-------------+------+-----+---------+-------+
>| username | varchar(12) |      | PRI |         |       |
>| passwd   | varchar(12) |      |     |         |       |
>| email    | varchar(30) |      |     |         |       |
>+----------+-------------+------+-----+---------+-------+


-- 
Paul DuBois, paul@stripped
Thread
Strange Mysql behaviourWilliam Wong17 Jun
  • Re: Strange Mysql behaviourPaul DuBois17 Jun
  • Re: Strange Mysql behaviourWilliam Wong17 Jun
    • Re: Strange Mysql behaviourPaul DuBois17 Jun
  • Re: Strange Mysql behaviourSDiZ Cheng17 Jun
  • Re: Strange Mysql behaviourWilliam Wong17 Jun