Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql "where" and "or" statement

Tags:

mysql

I started to work on a Mysql query abut it keeps coming up with a error?

can some one look at it and tell me what i am doing wrong?

$query = ("select * from `users` where (`username`='$username' and `password`='$password' or select * from `users` where `$username `='$email' and `password`='$password')");

the error is

 mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a8423624/public_html/testchecklogin.php on line 57

which means that it hasn't found anyone. This means that my Query is wrong?

like image 470
Ryan Avatar asked Jul 03 '11 05:07

Ryan


1 Answers

The ... OR SELECT... is giving the error. I think you are trying to write that as:

$query = ("select * from `users` where (`username`='$username' OR `$username `='$email') and `password`='$password'");
like image 146
Tudor Constantin Avatar answered Oct 03 '22 01:10

Tudor Constantin