I'm having this error and I can't figure out why.
I have a form to add a user, and in the controller, I want to check if the email entered in the form doesn't already exist. But it throws me this error and I frankly don't understand the reason.
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''userlogin' WHERE 'email' = 'nba@gmail.com'' at line 1 in C:\xampp\htdocs\test\controllers\adduser.php:14 Stack trace: #0 C:\xampp\htdocs\test\controllers\adduser.php(14): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\test\controllers\adduser.php on line 14
my code is :
{
$emailsearch = $_POST['email'];
$query = $DBH->prepare("SELECT 'email' FROM 'userlogin' WHERE 'email' = ?");
$query->bindValue(1,$emailsearch);
$query->execute();
if($query->rowCount() > 0)
{
header('location:../views/adduser.php?status=danger&message='.urlencode('Adresse email existe déjà'));
}else{
$email = $_POST['email'];
}
} ```
Can someone tell me why please ? I really don't understand, my SQL syntax seems correct to me..
[![Here is my database :][1]][1]
[1]: https://i.stack.imgur.com/1EgyZ.png