我收到以下错误
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/