gpt4 book ai didi

更新数据库时PHP mysql错误

转载 作者:太空宇宙 更新时间:2023-11-03 12:15:38 24 4
gpt4 key购买 nike

我收到以下错误

Warning: PDOStatement::execute(): SQLSTATE[HY093]: 
Invalid parameter number: number of bound variables does not match number of tokens

当我尝试更新 MySQL 数据库时。

这是我使用的代码。

public function update() {
global $db;
$stmt = $db->prepare("UPDATE products SET Name='?', Cate_id='?', Price='?', Image='?', Special='?', Special_price='?', Disable='?' WHERE PID = ?;");
$stmt->execute(array($this->name, $this->category, $this->price, $this->image, $this->special, $this->special_price, $this->disable, $this->id));
}

最佳答案

SET Name='?', Cate_id='?', Price='?', Image='?'  etc

在 ?

中不需要引号

应该是

SET Name=?, Cate_id=?, Price=?, Image=? etc...

关于更新数据库时PHP mysql错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22375834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com