我遇到了一个错误,我不知道我的代码有什么问题。有人能帮我吗?SQL更新时出错
Error: UPDATE users SET voornaam = Test, achternaam = Test2, mail = [email protected], tel = ,adres = , geslacht = man, bestuur = 0, tc = 0, ic = 0, jec = 0, rvr = , instructeur = 0, webmaster = 0 WHERE id = 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'adres = , geslacht = man, bestuur = 0, tc = 0, ic = 0, jec = 0, rvr = , instruct' at line 1
$id = $_GET['u'];
$sql = "UPDATE users SET voornaam = $voornaam, achternaam = $achternaam,
mail = $mailadres, tel = $tel, adres = $adres, geslacht = $geslacht,
bestuur = $bestuur, tc = $tc, ic = $ic, jec = $jec, rvr = $rvr,
instructeur = $instructeur, webmaster = $webmaster WHERE id = ".$id."";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
外貌像你没有设置'$ tel'和'$ adres'的值,它们是空的吗?为了测试,考虑在字符串上使用引号(如'voornaam ='$ voornaam'')。但实际上,应该使用prepared语句。 – FirstOne
你的$ adres是空的,你的查询'adres ='给出错误,如果它们是空字符串,它应该是这样的qoutes:'adres ='$ adres'' – kakajan