2014-01-08 73 views
0

我運行這個PDO SQL查詢:PDO無效的參數號錯誤信息

$stmt = $pdo_conn->prepare("INSERT into ticket_updates (ticket_seq, notes, datetime, updatedby, customer, internal_message) values (:ticket_seq, :notes, :datetime, :updatedby, :customer, :internal_message) "); 
       $stmt->execute(array(':ticket_seq' => $ticketnumber, 
       ':notes' => addslashes($message), 
       ':datetime' => date("Y-m-d H:i:s"), 
       ':updateedby' => $last_updated_by, 
       ':customer' => 'Y', 
       ':internal_message' => 'no')); 

,但得到這個錯誤:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined' in /home/integra/public_html/autocheck/support_emails.php:479 Stack trace: #0 /home/integra/public_html/autocheck/support_emails.php(479): PDOStatement->execute(Array) #1 {main} thrown in /home/integra/public_html/autocheck/support_emails.php on line 479 

林不知道是什麼問題,所有其他查詢做工精細

回答

5

進入準備你調用這個參數updatedby,但進入綁定你有updateedby解決這個問題,也許它解決了你的錯誤。

+0

謝謝 - 對不起,它是漫長的一天! :) – charlie

+0

它發生在我們所有人身上 – Goikiu

0

可能是錯字,因爲錯誤消息說:參數未定義。仔細檢查你的參數。

0

在這種情況下,您可能需要使用未命名的參數。這將節省您輸入兩次並改善可維護性的麻煩,恕我直言。

$stmt = $pdo_conn->prepare(
    "INSERT into ticket_updates (". 
     "ticket_seq, notes, datetime, updatedby, customer, internal_message)". 
     "values (?, ?, ?, ?, ?, ?)"); 

$stmt->execute(array(
      $ticketnumber, 
      addslashes($message), 
      date("Y-m-d H:i:s"), 
      $last_updated_by, 
      'Y', 
      'no'));