我目前正在使用以公式檢查配方的projet。我接近尾聲,但我真的不明白我的錯誤是什麼。如果有人能向我解釋:致命錯誤:未捕獲的PDOException:SQLSTATE [42S22]:未找到列
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
這裏是我的代碼在那裏塊:
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'];
}
}
當我回聲$idingredient
我得到這樣成分的ID列表:6,9,11,12 ,1,5但似乎不被條款所喜歡,我在想爲什麼?
'('。$ idingredient。')' – hassan