我正試圖將數據數組傳遞給更新查詢以更新客戶記錄。然而,由於某種原因,「成功」頁面顯示我的詳細信息已更新,但它們不是。如果我調試和回聲UDPATE查詢沒有更新我的MySql數據庫時出錯
echo implode(', ', $update);
die();
我得到的結果
mem_first_name
='喬希,mem_last_name
= '鐵匠',mem_email
= '[email protected]',allow_email
=「0 '
對我來說這看起來很好。這是我的update_user功能
function update_user($mem_id, $update_data) {
$update = array();
array_walk($update_data, 'array_sanitize');
foreach ($update_data as $field=>$data) {
$update[] = '`' . $field . '` = \'' . $data . '\'';
}
mysql_query("UPDATE `members` SET " . implode(', ', $update) . " WHERE `mem_id` = '$mem_id'") or die(mysql_error());
}
而我的$ update_data陣列
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
$message = 'Your details have been updated';
} else {
if (empty($_POST) === false && empty($errors) === true) {
$update_data = array(
'mem_first_name' => $_POST['mem_first_name'],
'mem_last_name' => $_POST['mem_last_name'],
'mem_email' => $_POST['mem_email'],
'allow_email' => ($_POST['allow_email']) ? 1 : 0
);
update_user($session_member_id, $update_data);
header('Location: settings.php?success');
exit();
} else if (empty($errors) === false) {
$message = output_errors($errors);
}
}
所以我已經做了,我失去了我的反引號我破滅之後,因此列名不具有反勾
從終端工程執行查詢? – hjpotter92 2013-03-02 11:15:30
整個查詢在執行之前的輸出是什麼? – JamesHalsall 2013-03-02 11:15:33
更好,如果你可以打印執行線之前的查詢? – 2013-03-02 11:16:19