2012-01-12 58 views
0

請一些身體幫我驗證了很多次,但我找不到在那裏我做了一個錯誤Zend的分貝插入例外

SQLSTATE [23000]:完整性約束衝突:「關鍵」 1062重複項「Index_6」

這是我的代碼:

$first_name = $_POST ['firstName']; 
$middle_name = $_POST ['middleName']; 
$last_name = $_POST ['lastName']; 
$office_ph_no = $_POST ['officePhoneNumber']; 
$cell_ph_no = $_POST ['cellPhoneNumber']; 
$email = $_POST ['emailId']; 
$supervisor_name = $_POST ['supervisorName']; 
$supervisor_email = $_POST ['supervisorEmail']; 
$supervisor_ph = $_POST ['supervisorPhone']; 
$pass = $_POST ['password']; 

$sql = $db->query ("INSERT INTO user(user_id, title, first_name, last_name, user_identity_id, email_id, password, office_phone_number, public_id, session_id, address_id, created_by, last_modified_by, created_on, last_modified_on, is_activated, is_deprecated, middle_name, cell_phone_number, superviser_name, superviser_email, superviser_phone_number) 

VALUES (:p_user_id, :p_title, :p_first_name, :p_last_name, :p_user_identity_id, :p_email_id, :p_password, :p_office_phone_number, :p_public_id, :p_session_id, :p_address_id, :p_created_by, :p_last_modified_by, :p_created_on, :p_last_modified_on, :p_is_activated, :p_is_deprecated, :p_middle_name, :p_cell_phone_number, :p_superviser_name, :p_superviser_email, :p_superviser_phone)", 

    array (
'p_user_id' => '', 
'p_title' => NULL, 
'p_first_name' => $first_name, 
'p_last_name' => $last_name, 
'p_user_identity_id' => 'id', 
'p_email_id' => $email, 
'p_password' => $pass, 
'p_office_phone_number' => $office_ph_no, 
'p_public_id' => NULL, 
'p_session_id' => NULL, 
'p_address_id' => NULL, 
'p_created_by' => NULL, 
'p_last_modified_by' => NULL, 
'p_created_on' => '', 
'p_last_modified_on' => '', 
'p_is_activated' => '0', 
'p_is_deprecated' => '0', 
'p_middle_name' => $middle_name, 
'p_cell_phone_number' => $cell_ph_no, 
'p_superviser_name' => $supervisor_name, 
'p_superviser_email' => $supervisor_email, 
'p_superviser_phone' => $supervisor_ph 
) 
+1

哪列有約束?是否有一些列試圖放置NULL值,或者您嘗試使用$ _POST中的值填充列? – BartekR 2012-01-12 10:59:19

回答

1

在數組名稱爲 'P_ is_deprecated' 有一個空格。

+0

感謝您在更改我正在獲取完整性約束違規之後進行身份驗證:1062對於'Index_6'鍵的重複條目''此錯誤 – vvr 2012-01-12 10:49:06

+0

在您的數據庫中,此主鍵(Index_6)已被另一個主管使用(我supose是主管)驗證它。 – 2012-01-12 10:57:48

+0

謝謝你發現它。 – vvr 2012-01-12 11:09:15