Level 60
SELECT * FROM users WHERE email = ? AND password = ?
Add and operator between email and password
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've looked through all the other StackOverflow (and google) posts with the same problem, but none seemed to address my problem.
I am using PDO and PHP.
Login.php
function check($data)
{
$email = $data['email'];
$password = $data['password'];
$sql = "SELECT * FROM users WHERE email = ? password = ?";
$params = [$email, $password];
$result = $this->doSelect($sql, $params);
print_r($result);
//if (sizeof($result) > 0) {
// echo 'yes';
//} else {
// echo 'no';
//}
}
Model.php
function doSelect($sql, $values = [], $fetch = '', $fetchStyle = PDO::FETCH_OBJ) {
$stmt = self::$connection->prepare($sql);
foreach ($values as $key => $value) {
$stmt->bindValue($key + 1, $value);
}
$stmt->execute();
if ($fetch == '') {
$result = $stmt->fetchAll($fetchStyle);
} else {
$result = $stmt->fetch($fetchStyle);
}
return $result;
}
I get this error.
SELECT * FROM users WHERE email = ? AND password = ?
Add and operator between email and password
Please or to participate in this conversation.