Вопрос

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