MySQL INSERT错误

时间:2010-12-28 12:52:22

标签: php mysql

我收到了这个错误:

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

这是我的mysql查询代码:

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

请帮助和非常感谢!

3 个答案:

答案 0 :(得分:7)

DESC是mySQL中的保留字。

你需要将该字段放在反引号中:

`desc`="..."

也许可以考虑重命名该字段。

mySQL reserved words in the manual

答案 1 :(得分:1)

我认为DESC是一个保留词,试着用反引号来逃避它。

答案 2 :(得分:-1)

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