Php PDO更新:语法错误或访问冲突
我是PDO新手,正在编写更新查询:Php PDO更新:语法错误或访问冲突,php,mysql,sql,pdo,Php,Mysql,Sql,Pdo,我是PDO新手,正在编写更新查询: $sql = "UPDATE `users` SET(`uname` = :uname, `role` = :role, `fname` = :fname, `email` = :email, `mobile1` = :mobile1, `mobile2` = :mobile2,
$sql = "UPDATE `users`
SET(`uname` = :uname,
`role` = :role,
`fname` = :fname,
`email` = :email,
`mobile1` = :mobile1,
`mobile2` = :mobile2,
`education` = :education,
`division` = :division,
`district` = :district,
`sub_district` = :sub_district,
`address` = :address,
`looking_for` = :looking)
WHERE `id` = :id";
//$sql = "UPDATE `users` SET(`uname`=?,`role`=?,`fname`=?,`email`=?,`mobile1`=?,`mobile2`=?,`education`=?,`division`=?,`district`=?,`sub_district`=?,`address`=?,`looking_for`=?) WHERE `id`=?";
$st = $conn->prepare($sql);
//$res['sql'] = $st->queryString;
$params = array(
':uname' => $uname,
':role' => $role,
':fname' => $fname,
':email' => $email,
':mobile1' => $mobile1,
':mobile2' => $mobile2,
':education' => $edu,
':division' => $division,
':district' => $district,
':sub_district' => $sub_district,
':address' => $address,
':looking' => $looking,
':id' => $id
);
//$res['params'] = $params;
$r = $st->execute($params);
并获得:
SQLSTATE[42000]:语法错误或访问冲突:1064您有
SQL语法错误;检查与您的产品相对应的手册
MariaDB服务器版本,以便使用接近“(uname
=
'rahman@abc.def“,角色
='2',fname
='全名',电子邮件
='rahm'
在1号线
有人能告诉我我的代码出了什么问题吗
以下是我的表格结构:
移除
集合
零件周围的支架:
$sql = "UPDATE `users`
SET `uname` = :uname,
`role` = :role,
`fname` = :fname,
`email` = :email,
`mobile1` = :mobile1,
`mobile2` = :mobile2,
`education` = :education,
`division` = :division,
`district` = :district,
`sub_district` = :sub_district,
`address` = :address,
`looking_for` = :looking
WHERE `id` = :id";
检查:
括号用于子查询解释为什么要删除括号,对每个人都有好处,包括问题的未来访问者。
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]