MysQl错误:无效的参数号 [英] MysQl error : Invalid parameter number
本文介绍了MysQl错误:无效的参数号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到此错误:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /FondManager.class.php on line 69
尝试执行此操作时:
$Fond_Modif = $Manager->get($id);
$Fond_Modif->setContactname($_POST['name']);
$Manager->update($Fond_Modif);
这是有关的课程:
public function update(Fond $Fond)
{
$q = $this->_db->prepare('UPDATE fonds SET Name, ContactName, ContactPosition, ContactMail, ContactPhone, Website, MinTic, MaxTic WHERE id = :id');
$q->bindValue(':id', $Fond->id());
$q->bindValue(':name', $Fond->name(), PDO::PARAM_INT);
$q->bindValue(':contactname', $Fond->contactname(), PDO::PARAM_INT);
$q->bindValue(':contactposition', $Fond->contactposition(), PDO::PARAM_INT);
$q->bindValue(':contactmail', $Fond->contactmail(), PDO::PARAM_INT);
$q->bindValue(':contactphone', $Fond->contactphone(), PDO::PARAM_INT);
$q->bindValue(':website', $Fond->website(), PDO::PARAM_INT);
$q->bindValue(':mintic', $Fond->mintic(), PDO::PARAM_INT);
$q->bindValue(':maxtic', $Fond->maxtic(), PDO::PARAM_INT);
$q->execute();
}
推荐答案
您必须提及"查询中的所有占位符
You have to "mention" all placeholders in your query
$q = $this->_db->prepare("UPDATE fonds
SET Name = :name,
ContactName = :contactname,
ContactPosition = :contactposition,
ContactMail = :contactmail,
ContactPhone = :contactphone,
Website = :website
MinTic = :mintic,
MaxTic = :maxtic
WHERE id = :id");
PDO仅替换占位符.您必须将该占位符添加到查询中.
PDO replaces only placeholders. You have to add that placeholders to your query.
这篇关于MysQl错误:无效的参数号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文