MYSQL query with a $_POST variable
Posted: Wed Sep 18, 2013 6:37 pm
Hello all,
I would be very pleased if someone could help me to resolve this problem:
I just want to select data in a DB after a form. Here is the code:
$req = $bdd->prepare('SELECT * FROM `nameoftable` WHERE `brand`=?');
$req->execute(array($_POST["brand"]));
while($donnees = $req->fetch()){"
The _POST variable is defined but it seems like it cannot be recognized as a string.
This manner works for numbers but not sentences. So Imagine there is the word "TURTLE" in my post variable it will not work but if a wrote: $req = $bdd->query('SELECT * FROM `nameoftable` WHERE `brand`= TURTLE');
then it will work.
Thank you very much for your Help
I would be very pleased if someone could help me to resolve this problem:
I just want to select data in a DB after a form. Here is the code:
$req = $bdd->prepare('SELECT * FROM `nameoftable` WHERE `brand`=?');
$req->execute(array($_POST["brand"]));
while($donnees = $req->fetch()){"
The _POST variable is defined but it seems like it cannot be recognized as a string.
This manner works for numbers but not sentences. So Imagine there is the word "TURTLE" in my post variable it will not work but if a wrote: $req = $bdd->query('SELECT * FROM `nameoftable` WHERE `brand`= TURTLE');
then it will work.
Thank you very much for your Help