I currently work on a projet which display a recipe with ingredients checked in a formular. I near to the end but i really not understand what is my error. If someone can explain to me :
Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column '$idingredient' in 'where clause' in /homepages/30/d675437312/htdocs/assets/recettemalin/recetteselectionnee.php:55 Stack trace: #0 /homepages/30/d675437312/htdocs/assets/recettemalin/recetteselectionnee.php(55): PDO->query(' SELECT DIST...') #1 {main} thrown in /homepages/30/d675437312/htdocs/assets/recettemalin/recetteselectionnee.php on line 55
Here's my code where it block :
if (isset($_POST['ingredients'])) {
$idingredient = implode(",", $_POST['ingredients']);
echo $idingredient.'<br>';
$recette = $bdd->query(' SELECT DISTINCT r.*
FROM ingredient i
INNER JOIN contient c
ON i.id_i = c.id_i
INNER JOIN recette r
ON c.id_r = r.id_r
WHERE i.id_i IN ($idingredient)');
while ($donnees = $recette->fetch()) {
echo $donnees['nom_r'];
echo $donnees['type_r'];
echo $donnees['description'];
}
}
When I echo $idingredient I get a list of id of ingredient like this : 6,9,11,12,1,5 but it seem's to not be liked by the clause where and I'm wondering why ?