插入數據庫時出錯。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