它一直显示此错误
错误:UPDATE帐户SET basic = WHERE username ='Admin'; 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的'WHERE username ='Admin''附近使用正确的语法
<?
session_start();
?>
<?php
$servername = "xxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user = $_SESSION["sess_user"];
$sql = "UPDATE accounts SET basic = WHERE username = $user ";
if ($conn->query($sql) === TRUE) {
header("Location: member.php");
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
答案 0 :(得分:1)
$sql = "UPDATE accounts SET basic = WHERE username = $user ";
将此更改为
$sql = "UPDATE accounts SET basic="value" WHERE username = $user ";
在=
之后你没有给出任何价值<强>编辑强>
$sql="update accounts set fraternity='basic' where username = '".$user."'";