本文介绍了PDOStatement :: execute():SQLSTATE [HY093]:无效的参数编号:参数未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码,我无法解决此错误.任何帮助表示赞赏.我正在尝试更新数据库中的表.
Below is my code, I am not able to resolve this error. Any help is appreciated. I am trying to update a table in my database.
public function updateUnit($params){
$user = 'monil';
$password = 'Masters123';
$dbh = new \PDO('mysql:host=127.0.0.1;dbname=tcsdb', $user, $password);
$task=array(':UnitCode'=>$params['UnitCode'],':UnitDescription'=>$params['UnitDescription'] ,
':UnitName'=>$params['UnitName'], ':UnitID'=>$params['UnitID']);
echo $params['UnitID'];
$sth = $dbh->prepare('UPDATE unit SET UnitCode = :UnitCode,'
. 'UnitDescription = :UnitDescription,UnitName = :UnitName WHERE UnitId=:UnitId');
$sth->execute($task);
return true;
}
推荐答案
:UnitID != :UnitId
参数区分大小写.
这篇关于PDOStatement :: execute():SQLSTATE [HY093]:无效的参数编号:参数未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!