0

Well I'm getting this error:

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

For the following code:

$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')";

Everything looks fine to me.. what's wrong?

Imri Persiado
  • 1,857
  • 8
  • 29
  • 45

4 Answers4

2

DESC is a reserved keyword. you should put it as `DESC` to escape it.

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')
Filipe Silva
  • 21,189
  • 5
  • 53
  • 68
1

DESC is a reserved keyword and you cannot have that as a column else surround it using a backtick operator .

Here..

$sql="INSERT INTO page(title,css,favicon,charset,keywords,author,desc,fb_t
                                                     ------------^

Disclaimer: Stop using mysql_* functions as they are deprecated. Switch to MySQLi or PDO instead.

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
1

Add Backtic around desc because its a reserve word

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')
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
0

desc is reserved keyword of 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')";
Harish Singh
  • 3,359
  • 5
  • 24
  • 39