这段代码有什么问题,它告诉我这个,但我看不出有什么不好:
Error : 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 'WHERE B='achillea_millefolium_credo'' at line 1
这是我的代码:
(之前)信息:如果我们回显“$all_db_types_associations['nom_url']”,它将回显“B”(我数据库中的 B 列)
如果我们回显“$plante”,它将回显“achillea_millefolium_credo”(植物的名称)
$plante_undecoded = htmlspecialchars($_GET["plante"]);
$plante = htmlspecialchars_decode(htmlspecialchars_decode($plante_undecoded));
try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=' .$host .';dbname=plantes', $username, $password, $pdo_options);
$bdd->query("SET NAMES 'utf8'");
$pdo = 'SELECT * FROM ' .$current_db_name ." ORDER BY " .$all_db_types_associations['nom_bot'] ." WHERE " .$all_db_types_associations['nom_url'] ."=? ";
//echo $pdo ." <br />";
$reponse = $bdd->prepare($pdo);
$reponse->execute(array($plante));
while ($donnees = $reponse->fetch())
{
//things here...
}
$reponse->closeCursor();
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
是因为我在 MySQL 中的列名是大写字母(“B”)吗?否则……什么大?