即時通訊嘗試寫一個非常(所謂)簡單的代碼將數據放入我的數據庫。在我的SQL語法錯誤不會允許插入表
$sql = "INSERT INTO `clubevent` (clubevent_id ,club_id ,event_id ,theme_id ,clubevent_date ,clubevent_start_time ,clubevent_finish_time ,clubevent_cost) VALUES (NULL , $clubstate, $eventstate, $themestate, $datestate, $sTimestate, $fTimestate, $coststate)";
但我不斷收到一條消息
Error: INSERT INTO
clubevent
(clubevent_id ,club_id ,event_id ,theme_id ,clubevent_date ,clubevent_start_time ,clubevent_finish_time ,clubevent_cost) VALUES (NULL , 4, 14, 2, 2016-04-26, 23:00:00, 05:00:00, 05) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':00:00, 05:00:00, 05)' at line 1
數據IM試圖擠進這個是:
4, 14, 2, 2016-04-26, 23:00:00, 05:00:00, 05
有誰能夠闡明這個問題一些輕?
您有引文錯誤。使用準備好的聲明,你不會有這個問題。 –
我同意,使用準備好的聲明來解決。這就是說,你有問題的原因是因爲你的日期/時間沒有逃脫。它讀取分號作爲break,導致錯誤 – Doug
如果這是sql server,爲什麼你要將標記爲mysql? – e4c5