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

时间:2015-04-06 18:41:02

标签: 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->错误,它们看起来都很干净但是没有保存到表中。这里使用的函数在其他地方使用并且工作正常。任何猜测?

1 个答案:

答案 0 :(得分:0)

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

是你的朋友,你为什么总是在旅途中将他排除在外?