我试图用与数组形式参数的简单的MySQL插入查询。 它不断告诉我的参数的数量是错误的。 我曾尝试以下,所有生产的同样的错误:
$stmt3 = $link->prepare('INSERT INTO messages VALUES(null, :room, :name, :message, :time, :color)');
$stmt3->execute(array(':room' => $Clean['room'],':name' => $Clean['name'],':message' => $Clean['message'],':time' => $time,':color:' => $Clean['color']));
和
$stmt3 = $link->prepare('INSERT INTO messages VALUES(:null, :room, :name, :message, :time, :color)');
$stmt3->execute(array(':null' => null, ':room' => $Clean['room'],':name' => $Clean['name'],':message' => $Clean['message'],':time' => $time,':color:' => $Clean['color']));
以及声明的列特地避开空插入:
$stmt3 = $link->prepare('INSERT INTO messages (room, name, message, time, color) VALUES(:room, :name, :message, :time, :color)');
$stmt3->execute(array(':room' => $Clean['room'],':name' => $Clean['name'],':message' => $Clean['message'],':time' => $time,':color:' => $Clean['color']));
这是使用PDO(我通常使用的mysqli我的第一次,但我目前的共享主机不具备mysqlnd插件,阻止我准备使用(),所以从这个角度看任何见解表示赞赏。