插入数据库时出错。PHP SQL插入错误
代码:
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','
不知道为什么被抛出这个错误!
为什么不把所有的数据都放入变量中。稍后更容易INSERT。例如:$ title = clean($ commentss ['title']) – s3polz
您可以打印查询并查看它是如何构建的,然后执行 – Deepak