PDO错误:参数号无效:绑定变量数与令牌数不匹配'

时间:2013-12-27 08:57:24

标签: php pdo

我是PDO的新手,并创建了一个更新查询,我收到了上述错误。可能是因为凌晨4点,但我看不出我错过了什么。这是查询:

$uid = $_GET['uid'];

print_r($_POST);

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$home_address = $_POST['home_address'];
$city = $_POST['city'];
$province = $_POST['province'];
$country = $_POST['country'];
$postal_code = $_POST['postal_code'];
$phone = $_POST['phone'];
$buisness_phone = $_POST['buisness_phone'];
$buisness_email = $_POST['buisness_email'];
$employer = $_POST['employer'];
$primary_email = $_POST['primary_email'];

$query = "UPDATE primary_profile
SET fName = :first_name,
lName = :last_name,
hAddress = :home_address,
city = :city,
province = :province,
country = :country,
pCode = :postal_code,
phone = :phone,
bPhone = :buisness_phone,
bEmail = :buisness_email,
email = :primary_email,
employer = :employer
WHERE uid = :uid";


$stmt = $conn->prepare($query);
$stmt->execute(array(':first_name'=>$first_name,
':last_name'=>$last_name,
':home_address'=>$home_address,
':city'=>$city,
':province'=>$province,
':country'=>$country,
':postal_code'=>$postal_code,
':phone'=>$phone,
':buisness_phone'=>$buisness_phone,
':buisness_email'=>$buisness_email,                  ':primary_email'=>$primary_email,                           
':employer'=>$employer
));

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:2)

您的查询中有13个命名占位符,但只绑定了11个变量。绑定最后一个它应该工作。 (UID)