PDO stmt->执行导致MySQL语法错误

时间:2013-04-14 22:21:41

标签: php mysql pdo

有谁可以帮我弄清楚为什么以下代码会返回MySQL语法错误?

$stmt = $pdo->prepare('INSERT INTO `message`(`id`, `message`, 
        `scramble_level`, `scramble_key`) 
        VALUES (:id, :message, :scramble_level, :scramble_key');


$stmt->execute(array(':id' => 'NOW()', ':message' => $theMessage, 
        ':scramble_level' => $scrambleLevel, 
        ':scramble_key' => $scrambleKey));

这导致:

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 '' at line 3

1 个答案:

答案 0 :(得分:5)

您错过了)

周围的结束括号VALUES()
VALUES (:id, :message, :scramble_level, :scramble_key)');