好吧,我收到了这个错误:
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 'desc,fb_title,fb_pic,fb_url,fb_desc) VALUES('', '', '', '', '', '', '', ''' at line 1
以下代码:
$sql="INSERT INTO page(title,css,favicon,charset,keywords,author,desc,fb_title,fb_pic,fb_url,fb_desc)
VALUES('$title', '$css', '$favicon', '$charset', '$keywords', '$author', '$desc', '$fb_title', '$fb_pic', '$fb_url', '$fb_desc')";
一切看起来都很好......怎么了?
答案 0 :(得分:2)
DESC是保留关键字。你应该把它作为`DESC`
来逃避它。
INSERT INTO page(title,css,favicon,charset,keywords,author,`desc`,fb_title,fb_pic,fb_url,fb_desc)
VALUES('$title', '$css', '$favicon', '$charset', '$keywords', '$author', '$desc', '$fb_title', '$fb_pic', '$fb_url', '$fb_desc')
答案 1 :(得分:1)
DESC
是一个保留关键字,您不能使用反引号操作符将其作为其他方式包围它。
下面..
$sql="INSERT INTO page(title,css,favicon,charset,keywords,author,desc,fb_t
------------^
免责声明:不推荐使用mysql_ *函数,因为它们已被弃用。改为使用MySQLi或PDO。
答案 2 :(得分:1)
在desc
附近添加反引号,因为它是一个保留字
INSERT INTO page(title,css,favicon,charset,keywords,author,`desc`,fb_title,fb_pic,fb_url,fb_desc)
VALUES('$title', '$css', '$favicon', '$charset', '$keywords', '$author', '$desc', '$fb_title', '$fb_pic', '$fb_url', '$fb_desc')
答案 3 :(得分:0)
desc是mysql的保留关键字
$sql="INSERT INTO page(`title`, `css`, `favicon`, `charset`, `keywords`, `author`,`desc`,`fb_title`,`fb_pic`,`fb_url`,`fb_desc`)
VALUES('$title', '$css', '$favicon', '$charset', '$keywords', '$author', '$desc', '$fb_title', '$fb_pic', '$fb_url', '$fb_desc')";