SQL语法错误;检查与MySQL服务器版本对应的手册

SQL语法错误;检查与MySQL服务器版本对应的手册,mysql,sql,Mysql,Sql,HTML代码 <!DOCTYPE html> <html> <head> <style> #right { margin-top:109px; margin-right:225px; } #button { margin-right:; margin-top:22px; } </style> &

HTML代码

<!DOCTYPE html>
<html>
  <head>
    <style>
      #right
      {
      margin-top:109px;
      margin-right:225px;
      }
      #button
      {
      margin-right:;
      margin-top:22px;
      }
    </style>
  </head>
  <body>
    <div id="total" style="width:1350px">
      <div id="top" style="width:1350px;height:69px;background-image:url('top.png');float:;"></div>
      <div id="body" style="width:1350px;height:570px;background-image:url('body.jpg');float:;">
        <div id="right" style="background-color:;height:283px;width:320px;float:right;">
          <form action="new.php" method="post" >
            <input type="text" name="username" value="" size="37"  placeholder="username"style="height:20px"><br><br>
            <pre><input type="password" name="password" value="" size="37" placeholder="password"style="height:20px"> 
<div id="button"><input type="image" name="" value="submit" src="button.png" />  <input type="checkbox" value="check"><br></pre>
            </div>
          </form>
        </div>
      </div>
      <div id="footer" style="width:1350px;height:33px;background-image:url('footer.png');clear:both;"></div>
    </div>
  </body>
</html>

#对
{
利润上限:109px;
右边距:225px;
}
#钮扣
{
保证金权利:;
边缘顶部:22px;
}


<?php
$con=mysqli_connect("localhost","prabha","prabha","prabha");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO table (username, password)
VALUES
('$_POST[username]','$_POST[password]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "1 record added";

mysqli_close($con);
?>

<?php
$con=mysqli_connect("localhost","prabha","prabha","prabha");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO table (username, password)
VALUES
('$_POST[username]','$_POST[password]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "1 record added";

mysqli_close($con);
?>
我的PHP代码

$sql="INSERT INTO `table` (`username`, `password`)
VALUES
('$_POST[username]','$_POST[password]')";

对MYSQL保留字使用`反勾号

表名“table”是MYSQL的保留字

因此,您的查询应该如下所示

$query="INSERT INTO `tablename` (`name`, `email`)
VALUES
('$_POST[name]','$_POST[email]')";

某些特殊字符会给出这种类型的错误,因此请使用


不要叫你的表
-它不仅是一个保留字,而且在清晰度和文档方面也是一个可怕的名称。谢谢你们,我对所有这些东西都是新手…,我使用了不同的表名它工作起来非常酷。。。。。。。。。。。。。