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->錯誤,這一切看起來和運行乾淨的,但不保存表。這裏使用的函數在其他地方使用並且正常工作。任何猜測?
做過任何基本的調試,比如檢查返回值?你的代碼基本上假設什麼都不會出錯。 mysqli在失敗時返回布爾值false。 –
爲了簡潔起見,我忽略了任何錯誤檢查,但相信我,是的,我檢查了每個步驟的錯誤。沒有錯誤報告。 –
你有autocommit被禁用? –