好吧,似乎有关于这个主题的许多问题,但我很奇怪。 我运行此查询:SQL返回错误:'字段列表'中的未知列“g”
INSERT INTO `blogposts` (id,author,subject,content,date) VALUES (2,$author,$subject,$content,$date)
而得到这个错误:
Unknown column 'g' in 'field list'
我在表中没有列 'G',所以发生了什么?
好吧,似乎有关于这个主题的许多问题,但我很奇怪。 我运行此查询:SQL返回错误:'字段列表'中的未知列“g”
INSERT INTO `blogposts` (id,author,subject,content,date) VALUES (2,$author,$subject,$content,$date)
而得到这个错误:
Unknown column 'g' in 'field list'
我在表中没有列 'G',所以发生了什么?
如果您使用的任何变量都是字符串,则需要在查询中用引号括起来。如果其中一个变量的值是“g”,并且它被插入查询而没有引号,MySQL将查找列“g”。
INSERT INTO `blogposts` (`id`,`author`,`subject`,`content`,`date`) VALUES (2,"$author","$subject","$content","$date")
SQL注入操作? – 2013-03-19 21:28:35