select count avec implode
Bonjour a tous,
je sèche sur une erreur dont je ne trouve pas l'origine.
si quelqu'un pourrait m'éclairer :roll:
Citation:
erreur : Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'departement=1 OR departement=2 OR departement=3 OR departement=4 OR departement='
code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
$departs = $_POST['depart'];
$departs = implode(" OR departement=", $departs);
$departs = "departement=".$departs;
// Post de la requete
if($departs == NULL)
{
$requete = $departs;
$smarty->assign('requete',$requete);
}
else
{
$requete = $departs;
$smarty->assign('requete',$requete);
}
// nombre d'offres
$offremotclef = $connexion -> query("SELECT count(*) AS id_offre FROM offres WHERE valide=1 ".$requete." ")->fetchColumn();
$smarty->assign('offremotclef',$offremotclef); |