我正在我的網站上工作,並且正在嘗試創建一個設置頁面,允許他們更改密碼,但是每次我嘗試更改密碼時,它都會顯示Query failed
,if你可以發現問題,這將是一個很大的幫助;SQL查詢失敗[密碼更改]
require_once('config.php');
require_once('auth.php');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$password = clean($_POST['password']);
$retpassword = clean($_POST['retpassword']);
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
if($retpassword == '') {
$errmsg_arr[] = 'Please retype your password';
$errflag = true;
}
if(strcmp($password, $retpassword) != 0) {
$errmsg_arr[] = 'New passwords do not match!';
$errflag = true;
}
//If there are input validations, redirect back to the settings page
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: settings.php");
exit();
}
$qry = "UPDATE members SET passwd = ".md5($_POST['password'])." WHERE member_id = ".$_SESSION['SESS_MEMBER_ID']."";
$result = @mysql_query($qry);
if($result) {
header("location: changed.php");
exit();
}else {
die("Query failed");
}
?>
使用'mysql_error()'來找出哪裏出了問題。 –
@皮卡웃謝謝! – user2331568