Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL语法错误&引用;检查与您的MySQL服务器版本相对应的手册;_Php_Sql_Mysql_Mysql Error 1064 - Fatal编程技术网

Php MySQL语法错误&引用;检查与您的MySQL服务器版本相对应的手册;

Php MySQL语法错误&引用;检查与您的MySQL服务器版本相对应的手册;,php,sql,mysql,mysql-error-1064,Php,Sql,Mysql,Mysql Error 1064,我一直在互联网上寻找以下错误的解决方案 "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 'primary, username, password, password2) VALUES (null, 'hello', 'hello', 'hello')' at line 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 'primary, username, password, password2) VALUES (null, 'hello', 'hello', 'hello')' at line 1"
我不知道发生了什么事。。我知道你会问我的代码是什么,所以在这里:

$con = mysql_connect("localhost","root","*****");
    if (!$con)
      {
      die('Server overload, please try again' . mysql_error());
      }

    mysql_select_db("users", $con);

    $sql = "INSERT INTO details (primary, username, password, password2) VALUES (null, '$_POST[username]', '$_POST[password]', '$_POST[password2]')";

    if (!mysql_query($sql,$con))
      {
      die('Error: Server overload, try again' . mysql_error());
      }
    echo "You have signed up successfully!";

    mysql_close($con);
我已经花了大约4/5个小时试图解决这个问题,但没有成功
谢谢,

劳伦斯初级是一个保留字。什么是表格定义


主是一个保留字。什么是表格定义


我将第一列重命名为其他内容:“primary”是MySQL中的保留字:


我将第一列重命名为其他内容:“primary”是MySQL中的保留字:

在SQL中是a,这意味着您应该:

  • 重新命名那个专栏——这是个好主意,以避免这种情况
  • 或者在该名称周围使用反勾号
下面是第二种情况下的查询:

INSERT INTO details (`primary`, `username`, `password`, `password2`)
VALUES (null, 'hello', 'hello', 'hello')

注意:你应该用,来逃避你的价值观

primary
在SQL中是a,这意味着您应该:

  • 重新命名那个专栏——这是个好主意,以避免这种情况
  • 或者在该名称周围使用反勾号
下面是第二种情况下的查询:

INSERT INTO details (`primary`, `username`, `password`, `password2`)
VALUES (null, 'hello', 'hello', 'hello')


注意:你应该用,来逃避你的价值观

尽量不要用相对通用的名称命名表或列,如primary和details

虽然它们可能不是您当前使用的SQL风格中的保留字,但您永远不知道何时可能支持其他类型(Postgres、Oracle等)

你也可以用这个方便的花花公子

后续问题:
我想知道是谁写了你得到的错误声明,基本上说是RTM?令人捧腹的我将在下一次尝试中使用该选项。:)


尽量不要用相对通用的名称命名表或列,如primary和details

虽然它们可能不是您当前使用的SQL风格中的保留字,但您永远不知道何时可能支持其他类型(Postgres、Oracle等)

你也可以用这个方便的花花公子

后续问题:
我想知道是谁写了你得到的错误声明,基本上说是RTM?令人捧腹的我将在下一次尝试中使用该选项。:)

我刚在谷歌上搜索到“你的SQL语法有错误,请查看手册”。也许你只是在谷歌上搜索整个错误?前几个结果都是正确的答案,我只是在谷歌上搜索了一下“你的SQL语法有错误,请查看手册”。也许你只是在谷歌上搜索整个错误?最初的几个结果是正确的答案。谢谢:)我认为这将是一个简单的错误!把一切都解决了。不客气:-);;别忘了“逃避你的价值观”部分!谢谢:)我以为这是个简单的错误!把一切都解决了。不客气:-);;别忘了“逃避你的价值观”部分!