Bricktop Posted March 10, 2008 Share Posted March 10, 2008 Hi Guys, Is it possible to have two operators in one Query? For example: SELECT * FROM table WHERE username=$username AND password=$password AND answer=$answer I have tried the above and it doesn't work - where am I going wrong please? How do I write the above so it will work? Thanks in advance Quote Link to comment Share on other sites More sharing options...
trq Posted March 10, 2008 Share Posted March 10, 2008 Yes its possible, you mistake however is tat strings need to be surrounded in quotes. SELECT * FROM table WHERE username='$username' AND password='$password' AND answer='$answer' passowrd will also required backticks I believe because it is the name of a mysql function.... SELECT * FROM table WHERE username='$username' AND `password`='$password' AND answer='$answer' Quote Link to comment Share on other sites More sharing options...
Thomisback Posted March 10, 2008 Share Posted March 10, 2008 Try: SELECT * FROM table WHERE userName = '$username' AND userPassword = '$password'" AND answer = '$answer'"; Quote Link to comment Share on other sites More sharing options...
revraz Posted March 10, 2008 Share Posted March 10, 2008 That would require him to change his fieldname. And why would you change the Case? Try: SELECT * FROM table WHERE userName = '$username' AND userPassword = '$password'" AND answer = '$answer'"; Quote Link to comment Share on other sites More sharing options...
Bricktop Posted March 10, 2008 Author Share Posted March 10, 2008 Hi there, neither of these seem to work - just says the credentials supplied are incorrect Any other ideas please? My code is as follows: $sql="SELECT * FROM authenti WHERE username='$username' email='$email' and password='$password'"; Thanks Quote Link to comment Share on other sites More sharing options...
Bricktop Posted March 10, 2008 Author Share Posted March 10, 2008 lol sry missed the "AND" working now! Thanks for all your help guys! Quote Link to comment Share on other sites More sharing options...
Thomisback Posted March 10, 2008 Share Posted March 10, 2008 That would require him to change his fieldname. And why would you change the Case? Try: SELECT * FROM table WHERE userName = '$username' AND userPassword = '$password'" AND answer = '$answer'"; My bad, should have been: SELECT * FROM table WHERE userName = '$username' AND Password = '$password'" AND answer = '$answer'"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.