Php 语法错误或访问冲突:1064您的SQL语法有错误;

Php 语法错误或访问冲突:1064您的SQL语法有错误;,php,mysql,Php,Mysql,我在以下代码中遇到了一些奇怪的错误: date_default_timezone_set('Europe/London'); $date = date("Y-m-d H:i:s"); $stmt = $this->registry->db->getDB()->prepare("INSERT INTO `comments` (date_posted,comment) VALUES ?,?"); $stm

我在以下代码中遇到了一些奇怪的错误:

date_default_timezone_set('Europe/London');
            $date = date("Y-m-d H:i:s");    
            $stmt = $this->registry->db->getDB()->prepare("INSERT INTO `comments` (date_posted,comment) VALUES ?,?");
        $stmt->execute(array($date,$comment));
检查与MySQL服务器版本对应的手册,了解 在第1行“2015-04-27 15:26:31”附近使用正确的语法,“非常好” 在C:\wamp\www\model\qualityControlModel.class.php的第161行

date_default_timezone_set('Europe/London');
            $date = date("Y-m-d H:i:s");    
            $stmt = $this->registry->db->getDB()->prepare("INSERT INTO `comments` (date_posted,comment) VALUES ?,?");
        $stmt->execute(array($date,$comment));

有人知道为什么会发生这种情况吗?

查询行的正确语法包括所有括号,包括围绕
值的括号:

date_default_timezone_set('Europe/London');
            $date = date("Y-m-d H:i:s");    
            $stmt = $this->registry->db->getDB()->prepare("INSERT INTO `comments` (date_posted,comment) VALUES ?,?");
        $stmt->execute(array($date,$comment));
$stmt = $this->registry->db->getDB()->prepare("INSERT INTO `comments` (date_posted,comment) VALUES (?,?)");

请花时间阅读如何使用准备好的陈述。这本可以完全避免这个问题。为什么每个人都报告他们的错误为“怪异”?是的,嗯,山姆?这太奇怪了,杰布兰查德,我们不是都很奇怪吗,拉尔夫@弗雷德二世,只有在新月山姆-@Jayblanchard之后我们才有1档,2档。OP可能还不够努力。