문제

I have the following query:

  $select_query = "SELECT * FROM users WHERE userName='$user_name', password='$password'";

The problem is that the query always fail, so how can I fix the 'WHERE' condition?

도움이 되었습니까?

해결책

You need to use AND

$select_query = "SELECT * FROM users WHERE userName='$user_name' AND password='$password'";

다른 팁

You'll need boolean logic for it:

$select_query = "SELECT * FROM users WHERE userName='$user_name' AND password='$password'";

Of course, this assumes you want the username and password to match. If you want either to match, you should use OR. This is all quite basic database stuff. Please read the documentation or get yourself a good book.

you need to use AND to separate your conditions.

where username ='$user_name' and password='$password'

Also, be aware that coding this way may make you vulnerable to SQL injection bugs/attacks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top