Maison > Article > développement back-end > 碰到鬼了,简单的数据库查询,显示Unknown column 'titletest' in 'field list'
遇到鬼了,简单的数据库查询,显示Unknown column 'titletest' in 'field list'
数据字段为:id(自增)、title(varchar(50)、content(longtext)
代码为
$title = $_POST['title']; (值为:titletest)
$content =$_POST['content'];(值为:contenttest )
$insert = "insert into article(title,content) values(".$title.','.$content.")";
错误为:Unknown column 'titletest' in 'field list'
代码为
$title = $_POST['title']; (值为:title test)这个和上面的多一个空格
$content =$_POST['content'];(值为:contenttest )
$insert = "insert into article(title,content) values(".$title.','.$content.")";
错误为:
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,contenttest)' at line 1
将$insert = "insert into article(title,content) values(".$title.','.$content.")";
中的$title, $content 换成字符串就可以插入
------解决方案--------------------
语句有问题, 换成这样 $insert = "insert into article(title,content) values('$title','$content')";
------解决方案--------------------
sql串得有问题,试试这个 $insert = "insert into article(title,content) values('".$title."','".$content."')";
------解决方案--------------------
$insert = "insert into article (title,content) values(‘$title','$content’)";