PHP/MySQL : why my query doesn't work?

Solution:
You are binding only the email parameter, you dont need the 3 "s"
$reqVerif->bind_param("sss",$email);
try:
$reqVerif->bind_param("s",$email);
Answer
Solution:
mysqli prepared statements should work. Just change a couple of lines,
$reqVerif = $bdd->prepare('SELECT ID_utilisateur FROM utilisateurs WHERE Adresse_email = ?');
You are only selecting ONE string here ,so only list it once:
$reqVerif->bind_param("s",$email);
$reqVerif->execute();
For your select it is easiest to bind your results, like so:
$reqVerif->bind_result($ID_utilisateur);
$reqVerif->fetch();
Then you can echo out your result like so:
echo $ID_utilisateur;
and then close your object:
$reqVerif->close();
(of course you can do it like you did above; I just simplified this into its elements)
Edit: if you want to have it check if there are any rows (which is what it appears), you will need to store the result after the execution with this row:
$reqVerif->store_result();
and then you can do something like this:
$num=$reqVerif->num_rows;
and then check it:
if ($num > 0) {
echo $ID_utilisateur;
}
and then you can free the result before you close the object with this:
$reqVerif->free_result;
$reqVerif->close();
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: malformed utf-8 characters, possibly incorrectly encoded
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.