您好我收到此错误 错误:SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的“管理员”附近使用正确的语法
这是我的新消息脚本new.php,这是其中包含错误的
<?php
if(isset($_GET['new'])){
if(isset($_POST['submit'])){
$name = $_POST['name'];
$sub = $_POST['sub'];
$msg = $_POST['msg'];
$user3 = "SELECT * FROM `users` WHERE `username` = ".$name." ";
$result6 = mysqli_query($conn,$user3);
$row6 = mysqli_fetch_row($result6);
if (!$row6['id']) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
$username2 = $row6['id'];
$id = $_SESSION['id'];
if(!$name OR !$sub OR !$msg){
echo "please enter all feilds";
}
else{
$sql = " INSERT INTO `inbox`(`id`, `too`, `from`, `message`, `unread`, `Subject`) VALUES (NULL, '$username2', '$id', '$msg','0', '$sub')
";
}
if ($conn->query($sql) === TRUE) {
echo "Message Sent!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>
<div class="dark-matter">
<form action="" method="POST">
Username:<br />
<input type="text" placeholder="Enter username" name="name"><br />
Subject:<br/>
<input type="text" placeholder="Enter Subject" name="sub"><br/>
Message:<br />
<textarea name="msg" cols="40" rows="5" ... ></textarea><br />
<input type="submit" class="button" name="submit" value="submit">
</div>
<?php
}
?>