2012-10-22 166 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();