好奇的Mysql更新错误

时间:2015-11-04 15:48:20

标签: php mysql sql

我创建了一个巨大的Update查询,并且多次检查是否正确构建了everithing,但是服务器返回了我的错误:**" Uncaught exception' PDOException'有消息

  

' SQLSTATE [42000]:语法错误或访问冲突:1064您有   SQL语法错误;查看与您的手册相对应的手册   MySQL服务器版本,用于在')附近使用正确的语法。在第27行'"

如果你能解释我错误的来源,我将不胜感激。谢谢。

    $update_query = $dbh->prepare('UPDATE Credit_Requests
    SET creditAmount = :creditAmount, duration = :duration, insurance =       :insurance, 
title = :title, lastName = :lastName, firstName = :firstName, birthDay = :birthDay, street = :street, 
number = :number, zipCode = :zipCode, city = :city, country = :country, streetPrevious = :streetPrevious, 
numberPrevious = :numberPrevious, liveSince = :liveSince, mobilePhone = :mobilePhone, homePhone = :homePhone,
email = :email, workPhone = :workPhone, maritalStatus = :maritalStatus, nationality = :nationality,
permit = :permit, expire = :expire, border = :border, professional_status = :professional_status, 
employedSince = :employedSince, employedUntil = :employedUntil, employerName = :employerName, 
streetEmployer = :streetEmployer, numberEmployer = :numberEmployer, zipCodeEmployer = :zipCodeEmployer, 
cityEmployer = :cityEmployer, typeRevenu = :typeRevenu, yearlyBonus = :yearlyBonus, salary13th = :salary13th, 
additionalWork = :additionalWork, additionalRevenue = :additionalRevenue, 
secondEmployerName = :secondEmployerName, secondStreetEmployer = :secondStreetEmployer, 
secondNumberEmployer = :secondNumberEmployer, secondZipCodeEmployer = :secondZipCodeEmployer,
secondCityEmployer = :secondCityEmployer, secondEmployedSince = :secondEmployedSince, 
thirdEmployerName = :thirdEmployerName, anoterAdditionalRevenue = :anoterAdditionalRevenue, 
liveWith = :liveWith, spouse = :spouse, spouseTitle = :spouseTitle, spouseFirstName = :spouseFirstName, 
birthday_spouse = :birthday_spouse, spouseProfessionalStatus = :spouseProfessionalStatus, 
spouseEmployerName = :spouseEmployerName, spouseZipCodeEmployer = :spouseZipCodeEmployer, 
spouseCityEmployer = :spouseCityEmployer, spouseAddRevenue = :spouseAddRevenue, 
spouseTypeRevenue = :spouseTypeRevenue, revenueSpouse13th = :revenueSpouse13th, 
spouseChildren = :spouseChildren, children06 = :children06, children610 = :children610, 
children12 = :children12, addExpense = :addExpense, leasing1 = :leasing1, leasing1Bank = :leasing1Bank, 
credit1 = :credit1, credit1Bank = :credit1Bank, credit2 = :credit2, credit2Bank = :credit2Bank, 
otherBankCreditAmount = :otherBankCreditAmount, otherBankLocation = :otherBankLocation, 
regularExpenses = :regularExpenses, restraininOrder = :restraininOrder, 
restraininOrderAmount = :restraininOrderAmount, notes = :notes, refinance = :refinance, 
seizure = :seizure, id_status = :id_status, id_lang = :id_lang WHERE id = 1) 
');

$update_query->execute(array(

'creditAmount' => $creditAmount,
'duration' => $duration,
'insurance' => $insurance,
'title' => $title,
'lastName' => $lastName,
'firstName' => $firstName,
'birthDay' => $birthDay,
'street' => $street,
'number' => $number,
'zipCode' => $zipCode,
'city' => $city, 
'country' => $country,
'streetPrevious' => $streetPrevious,
'numberPrevious' => $numberPrevious,
'liveSince' => $liveSince,
'mobilePhone' => $mobilePhone,
'homePhone' => $homePhone,
'email' => $email,
'workPhone' => $workPhone,
'maritalStatus' => $maritalStatus,
'nationality' => $nationality,
'permit' => $permit,
'expire' => $expire,
'border' => $border,
'professional_status' => $professional_status,
'employedSince' => $employedSince,
'employedUntil' => $employedUntil,
'employerName' => $employerName, 
'streetEmployer' => $streetEmployer,
'numberEmployer' => $numberEmployer,
'zipCodeEmployer' => $zipCodeEmployer,
'cityEmployer' => $cityEmployer,
'typeRevenu' => $typeRevenu,
'yearlyBonus' => $yearlyBonus,
'salary13th' => $salary13th,
'additionalWork' => $additionalWork, 
'additionalRevenue' => $additionalRevenue,
'secondEmployerName' => $secondEmployerName,
'secondStreetEmployer' => $secondStreetEmployer,
'secondNumberEmployer' => $secondNumberEmployer,
'secondZipCodeEmployer' => $secondZipCodeEmployer,
'secondCityEmployer' => $secondCityEmployer,
'secondEmployedSince' => $secondEmployedSince,
'thirdEmployerName' => $thirdEmployerName,
'anoterAdditionalRevenue' => $anoterAdditionalRevenue,
'liveWith' => $liveWith,
'spouse' => $spouse,    
'spouseTitle' => $spouseTitle,
'spouseFirstName' => $spouseFirstName,
'birthday_spouse' => $birthday_spouse,
'spouseProfessionalStatus' => $spouseProfessionalStatus,
'spouseEmployerName' => $spouseEmployerName,
'spouseZipCodeEmployer' => $spouseZipCodeEmployer,
'spouseCityEmployer' => $spouseCityEmployer,
'spouseAddRevenue' => $spouseAddRevenue,
'spouseTypeRevenue' => $spouseTypeRevenue,
'revenueSpouse13th' => $revenueSpouse13th,
'spouseChildren' => $spouseChildren,
'children06' => $children06,
'children610' => $children610,
'children12' => $children12,
'addExpense' => $addExpense,
'leasing1' => $leasing1,
'leasing1Bank' => $leasing1Bank,
'credit1' => $credit1, 
'credit1Bank' => $credit1Bank,
'credit2' => $credit2,
'credit2Bank' => $credit2Bank,
'otherBankCreditAmount' => $otherBankCreditAmount,
'otherBankLocation' => $otherBankLocation,
'regularExpenses' => $regularExpenses,
'restraininOrder' => $restraininOrder,
'restraininOrderAmount' => $restraininOrderAmount,
'notes' => $notes,
'refinance' => $refinance,
'seizure' => $seizure,
'id_status' => $id_status,
'id_lang' => $lang
));
header('Location: ' .$_SERVER['PHP_SELF']. '');
}

1 个答案:

答案 0 :(得分:3)

删除括号:

WHERE id = 1) 

为:

WHERE id = 1

或包装整个条件:

WHERE (id = 1)