2015-04-06 61 views
0

在此先感谢大家的帮助。我有一个问题让我疯狂了好几个小时。我已经尝试了多次使用几种方法编写这个完整的错误检查。我尝试过在字段名称上使用单引号,我试着把一个SQL查询放在一个变量中,并将它传递给$ db-> prepare - 这一切都无济于事。我检查了我的权限,对我来说一切都很好。我确定这很简单,但是我很厌烦这件事,而我只是没有看到它。PHP Mysqli准备好声明 - 更新不更新

$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->错误,这一切看起来和运行干净的,但不保存表。这里使用的函数在其他地方使用并且正常工作。任何猜测?

+0

做过任何基本的调试,比如检查返回值?你的代码基本上假设什么都不会出错。 mysqli在失败时返回布尔值false。 –

+0

为了简洁起见,我忽略了任何错误检查,但相信我,是的,我检查了每个步骤的错误。没有错误报告。 –

+0

你有autocommit被禁用? –

回答

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

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