PHP Mysqli 准备语句 - 更新不更新

标签 php mysql mysqli

在此先感谢大家的帮助。我有一个问题让我发疯了几个小时。我已经尝试使用几种具有完整错误检查的方法多次编写此代码。我试过在字段名称上加上单引号,我试过将 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->e​​rror,它看起来和运行起来都很干净,但不会保存到表中。此处使用的功能在其他地方使用并且工作正常。有什么猜测吗?

最佳答案

error_reporting(-1);
ini_set('display_errors', 'On');

是你的 friend ,为什么你总是在旅途中排斥他?

关于PHP Mysqli 准备语句 - 更新不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29477428/

相关文章:

javascript - Laravel 如何将变量存储到数据库中并在每次点击时更新它

php - Laravel - 更改迁移文件名/类,迁移 :reset still looks for old class

php - 如何在 Laravel Nova Action 中使用接口(interface)存储库?

mysql - 如何将下面的 SQL 查询转换为 Laravel 查询?

php - 选择查询中的数组

php - error_message 变量在表单提交时不显示字符串值

mysql - 在 MYSQL 工作台中创建的数据库的文件位置

php - 连接 2 个表时出现错误 "unique table/alias"

php - MySQL Native Driver 和 MySQL Client Library 有什么不同

php - 在准备查询时,检查 ($stmt = $mysqli->prepare($query)) 是否为假有多重要?