【发布时间】:2012-10-04 03:18:06
【问题描述】:
插入数据库时出错。
代码:
dbquery("INSERT INTO site_news_comments (articleid,title,short,comment,timestamp,userid,main,type,topstory) VALUES ($article,'".clean($commentss['title'])."','','".mysql_real_escape_string($_POST['comment'])."',current_timestamp,'".USER_ID."','0','".$commentss['type']."','')");
忽略 dbquery,与 mysql_query 完全相同。
我收到的错误是:
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 ''title','short','
不知道为什么会抛出这个错误!
【问题讨论】:
-
为什么不先将所有数据放入变量中。以后更容易插入。例如:$title = clean($cmetss['title'])
-
你可以只打印查询并在执行之前查看它是如何构建的