2014-01-08 3 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')); 
관련 문제