欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

碰到鬼了,简单的数据库查询,显示Unknown column 'titletest' in 'field list'

程序员文章站 2022-03-30 20:00:19
...
遇到鬼了,简单的数据库查询,显示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’)";
碰到鬼了,简单的数据库查询,显示Unknown column 'titletest' in 'field list'

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频