2012-10-22 123 views
0

我正在使用PDO的更新功能更新表單。由於某種原因,它沒有經過。PDO更新故障

這裏是代碼:

$data = "UPDATE insuranceverificationdisclaimer SET InsCoName =:insur, PhoneNumber = :phone, Policy = :policy, InsuredName = :insurname 
, MailingAdrs = :mailingad, EffDate = :effdate, ExpDate = :expdate, Email1 = :email, YrVehicle = :yr, Make = :make 
, Model = :model, VIN = :vin, TraineeUserName = :user, EmpName = :empname, EmpCoName = :empcomp, AgencyNumber = :agnum 
, SignDate = :signdate, AgentName = :agname, AgentPhone = :agphone, AgentEmail = :agemail, Combinedlimit = :csl, bodyinjur = :body 
, bodyinjureachacc = :acc 
, propertydmg = :prop WHERE TraineeUsername = :user"; 
     echo"1"; 

$insertdata = $DBH->prepare($data); 
$insertdata->execute(array(':insur' => $compname, ':phone' => $phone , ':policy' => $policynum, ':insurname' => $nameofPolicyholder 
, ':mailingad' => $newMailingAdrs, ':effdate' => $Policyeffdate, ':expdate' => $Policyexpdate, ':email' => $newEmployeeEmail 
, ':yr' => $YearOfVehicle, ':make' => $MakeOfVehicle, ':model' => $ModelOfVehicle, ':vin' => $Vehicleid, ':user' => $username, ':empname' => $EmployeeName, ':empcomp' => $EmployeeCompanyName, ':agnum' => $Agencynum 
, ':signdate' => $TodaysDate, ':agname' => $agentname, ':agphone' => $agentphone, ':agemail' => $agentemail, ':csl' => $singlelimit 
, ':body' => $bodyinjur, ':acc' => $eachacc, ':prop' => $propertydmg)); 

, ':csl' => $singlelimit, ':body' => $bodyinjur, ':acc' => $eachacc, ':prop' => $propertydmg開始這是不正常的功能,這些都在數據庫整數,值是整數。如果我從select和數組中刪除它將工作,但除此之外它不會。

讓我知道你是否需要別的東西!

UDATED ---------------------------

不會去通過,一旦你打執行只是停留白頁。

+3

「不工作」是什麼意思?錯誤的結果?異常拋出? –

+0

執行後不執行 –

+2

當您在PHP中遇到一個白頁(致命錯誤)時,您需要打開display_errors。 '的error_reporting(E_ALL); ini_set('display_errors',1);' –

回答

0

您應該按照Michael Berkowski的建議打開錯誤報告。現在,我只能假設錯誤是由params數據類型未定義引起的。您可以嘗試以下操作:

$insertdata->bindParam(':insur', $compname, PDO::PARAM_STR); 
$insertdata->bindParam(':csl', $singlelimit, PDO::PARAM_INT); 
//...bind the other params 
$insertdata->execute();