好吧,似乎有關於這個主題的許多問題,但我很奇怪。 我運行此查詢: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