0
Subject Update Failed!!You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
I am stuck here can anyone help me what I am missing in this code.The error is in Update Query.
一切正常,當我寫的代碼(我用的是Dreamviwer代碼編輯器軟件,我沒有得到任何語法錯誤。然而,當我運行它,我得到這個錯誤: //處理形式主題更新失敗Mysql的
$id= $current_subject["Id"];
$name=mysql_prep($_POST["Name"]);
$position=(int)$_POST["Position"];
$visible=(int)$_POST["Visible"];
$query="UPDATE subjects SET Name='{$name}',Position=$position,Visible=$visible WHERE Id={$id}";
$result= mysqli_query($conn, $query);
if($result && mysqli_affected_rows($conn)==1){
//success
$_SESSION["message"]="Subject updated.";
redirect_to("manage_content.php");
}else{
//Failure
$message="Subject Update Failed" . $conn->error;
}
什麼是mysql_prep?我認爲你需要刪除UPDATE查詢 –
'echo $ query'中的{}。當你發現語法錯誤時,收起你的尾巴。 –