Zhaf
Zhaf

Reputation: 1884

MySQL INSERT error

I got this error :

Database problem occur, please try again later.
- Error in query: INSERT INTO main SET title ='', url='www.jerseymurah.com', kod='jerseymurah', owner='Hasbul Aqill', tag='jersey, football, world cup', since='Feb 2010', desc='ssfsfsfsfs'
- 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='ssfsfsfsfs'' at line 1 (Error #1064)
- File: /home/yosh/domains/yosh.my/public_html/demo/admincp/tambah-save.php

and this is my mysql query code :

$query = "INSERT INTO main SET title ='".$ttile."', url='".$url."', 
kod='".$kod."', owner='".$owner."', tag='".$tag."', since='".$since."', 
desc='".$desc."'";
$db->rq($query);

Please help and thanks a lot!

Upvotes: 2

Views: 251

Answers (3)

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

mysql_query("INSERT INTO main(title,url,kod,owner,tag,since,description) VALUES('$title','$url','$kod','$owner','$tag','$since','$desc')");

Upvotes: -1

Sjoerd
Sjoerd

Reputation: 75679

I think DESC is a reserved word, try escaping it with backticks.

Upvotes: 1

Pekka
Pekka

Reputation: 449813

DESC is a reserved word in mySQL.

You need to put that field in backticks:

`desc`="..."

maybe consider renaming the field.

mySQL reserved words in the manual

Upvotes: 7

Related Questions