Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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语法错误_Php_Mysql - Fatal编程技术网

Php Mysql语法错误

Php Mysql语法错误,php,mysql,Php,Mysql,**代码** $ah_title = $_POST['ah_title']; $ah_postin = $_POST['ah_postin']; $ah_content = $_POST['ah_content']; date_default_timezone_set('America/Los_Angeles'); $ah_date = date("m/d/y"); $ah_query = "INSERT INTO '$ah_title' (title,content,date) VALU

**代码**

$ah_title = $_POST['ah_title'];
$ah_postin = $_POST['ah_postin'];
$ah_content = $_POST['ah_content'];
date_default_timezone_set('America/Los_Angeles');   
$ah_date = date("m/d/y");
$ah_query = "INSERT INTO '$ah_title' (title,content,date) VALUES ('$ah_title','$ah_content','$ah_date') ";
**错误**

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 ''test' (title,content,date) VALUES ('test','test','02/09/12')' at line 1 

请您帮助我理解错误以及如何修复它。

不要将表名括在引号中

$ah_query = "INSERT INTO $ah_title (title,content,date) VALUES ('$ah_title','$ah_content','$ah_date') ";
请防止SQL注入

$ah_title = mysql_real_escape_string($_POST['ah_title'];

不清楚您正在使用什么作为数据库库,因此不知道具体的转义方法

不要使用单引号转义实体名称。使用反向报价

$ah_query = "INSERT INTO `$ah_title` (`title`,`content`,`date`) VALUES ('$ah_title','$ah_content','$ah_date') ";

您将插入到表“test”中。您有一个名为test的表吗?在$ahu标题中插入?你确定这是正确的吗?

DATE
是MySQL中的保留字。您需要在其周围使用反勾号,以及在表名周围使用反勾号,而不是单引号

@Cjueden将不得不为我们提供更多信息。我的车坏了-你能在电话里帮我修好它而不问我更多的细节吗?谢谢你eveyrone的快速回复我发现我需要桌子是$ahu postin而不是$sh_title谢谢你这是我的问题