PHP和mysql语法错误

PHP和mysql语法错误,php,mysql,syntax,Php,Mysql,Syntax,My register.php不会查询最简单的查询: <?php session_start(); /* Connect and Query database "accounts", then close connection */ $connection=mysql_connect("localhost","root",""); if (!$connection) { die('Cannot connect to MySQL. Error: ' . mysql_error())

My register.php不会查询最简单的查询:

<?php
session_start();

/* Connect and Query database "accounts", then close connection */
$connection=mysql_connect("localhost","root","");
if (!$connection)
{
    die('Cannot connect to MySQL. Error: ' . mysql_error());
}

$check_database = mysql_select_db("accounts", $connection);
if (!$check_database)
{
    die('Cannot connect to database. Error: ' . mysql_error());
}

/* Query database to save user's post */
/* If field "repostid=0", then the post is not a repost; if the field "repostid>0", then the post is a repost with the field linking to the id of the post to be reposted */ 
$result = mysql_query("INSERT INTO posts2 (from) VALUES ('h1')");
if (!$result)
{
    die('Cannot query. Error: ' . mysql_error());
}

/* Close Connection */
mysql_close($connection);

/* Redirect to user's page */
header("Location: /website/index.php", 404);
exit();

?>
您需要像
一样使用反勾号从
中转义

INSERT INTO posts2 (`from`) VALUES ('h1')
您需要像
一样使用反勾号从
中转义

INSERT INTO posts2 (`from`) VALUES ('h1')

加上,;在SQL语句的末尾以及PHP行的末尾,如下所示

$result = mysql_query("INSERT INTO posts2 (`from`) VALUES ('h1');");
下面是SQL Insert的一个示例:


插入客户(客户名称、城市、国家)的价值观(“红衣主教”、“斯塔万格”、“挪威”)

;在SQL语句的末尾以及PHP行的末尾,如下所示

$result = mysql_query("INSERT INTO posts2 (`from`) VALUES ('h1');");
下面是SQL Insert的一个示例:


插入客户(客户名称、城市、国家)的价值观(“红衣主教”、“斯塔万格”、“挪威”)

我真的打了个保留字?有什么机会。。。我觉得自己很愚蠢。谢谢大家!@肖娜:我真的打了一个保留字?有什么机会。。。我觉得自己很愚蠢。谢谢大家!@shawna供将来参考:哈哈,我甚至没有注意到他背上的虱子不见了,我只是把它们放在我的,因为。。。很好,juergen dAlso你不必像那样在查询中放分号,它在没有itHAHA的情况下工作,甚至没有注意到他的背部缺少刻度,我只是把它们放在我的,因为来自。。。很好,juergen dAlso,你不必像那样在查询中放分号,没有分号也可以