Mysql "where" and "or" statement
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 ha开发者_高级运维sn't found anyone. This means that my Query is wrong?
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'");
Try this query:
select * from `users`
where
(`username`='$username' or `username `='$email') and `password`='$password'
Works!
SELECT * FROM "users" WHERE (username = '".$username."' OR username = '".$email."') AND password = '".$password."'";
精彩评论