在此先感谢大家的帮助。我有一个问题让我发疯了几个小时。我已经尝试使用几种具有完整错误检查的方法多次编写此代码。我试过在字段名称上加上单引号,我试过将 SQL 查询放在变量中并将其传递给 $db->prepare —— 都无济于事。我检查了我的权限,对我来说一切都很好。我敢肯定这很简单,但我已经睡眼惺忪地看了一遍,只是没有看到它。
$db = OpenDBConn();
// $query = "UPDATE agent_profiles SET ";
// $query .= "website = ?, display_email = ?, primary_phone = ?, secondary_phone = ?, secondary_phone_type = ?, ";
// $query .= "address_1 = ?, address_2 = ?, city = ?, state = ?, zip = ?, country = ?, description = ? ";
// $query .= "WHERE agent_id = ?";
$stmt = $db->prepare("UPDATE agent_profiles SET
website=?,
display_email=?,
primary_phone=?,
secondary_phone=?,
secondary_phone_type=?,
address_1=?,
address_2=?,
city=?,
state=?,
zip=?,
country=?,
description=?
WHERE agent_id=?");
$stmt->bind_param('ssssssssssssi', $this->website, $this->display_email, $this->primary_phone, $this->secondary_phone, $this->secondary_phone_type, $this->address_1, $this->address_2, $this->city, $this->state, $this->zip, $this->country, $this->description, $this->agent_id);
$stmt->execute();
$stmt->close();
$db->close();
即使有完整的错误报告并修改代码以查找 $db->error,它看起来和运行起来都很干净,但不会保存到表中。此处使用的功能在其他地方使用并且工作正常。有什么猜测吗?
最佳答案
error_reporting(-1);
ini_set('display_errors', 'On');
是你的 friend ,为什么你总是在旅途中排斥他?
关于PHP Mysqli 准备语句 - 更新不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29477428/