2013-04-14 44 views
-1

任何人都可以幫我弄清楚爲什麼下面的代碼返回一個MySQL語法錯誤?PDO stmt->在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 

回答

5

您mising你的右括號)在你VALUES()

VALUES (:id, :message, :scramble_level, :scramble_key)'); 
+0

非常愚蠢的我,謝謝。 – Matt