我目前正在使用以公式检查配方的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