2016-11-11 157 views
1

在將數據插入MySql數據庫時出現錯誤。插入數據在MySQL WordPress數據庫錯誤期間出錯?

數據被成功地插入,但具有給定錯誤[WordPress database error: [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] '

以下查詢我用於數據庫中插入記錄。與像

INSERT INTO `wp_make_details` (`c_id`, `post_id`, `make_name`, `year`, `model_name`) values (NULL,'15904','Yamaha', '2006', 'Stratoliner, Stratoliner S, Stratoliner Midnight, Roadliner, Roadliner S , Roadliner Midnight, Road Star, Road Star Midnight, Road Star Silverado, Road Star Midnight Silverado, V-Star 650 Custom, V-Star 650 Midnight Custom, V-Star 650 Classic, V-Star 650 Silverado, V-Star 1100 Custom, V-Star 1100 Midnight Custom , V-Star 1100 Classic, V-Star 1100 Silverado, Road Star Warrior, Road Star Midnight Warrior, V-Max, Virago 250, Royal Star Venture, Royal Star Midnight Venture , Royal Star Tour Deluxe, FJR1300A, FJR1300AE, YZF600R, YZF-R1, YZF-R1 50th Anniversary Edition, YZF-R1 LE, YZF-R1 LE, YZF-R6, YZF-R6 50th Anniversary Edition, YZF-R6S, MT-01 , XJR1300 , FZ1, FZ1 Naked, FZ6 , MT-03 , XT225, TW200, YZ450F, YZ450F 50th Anniversary Edition, YZ250 , YZ250F, YZ250F 50th Anniversary Edition, YZ125 , YZ85 , WR450F, WR250F, TT-R250, TT-R230 , TT-R125LE , TT-R125L , TT-R125E , TT-R125, TT-R90E, TT-R90 , TT-R50E , PW80 , PW50, Majesty, Morphous, Vino, Vino 125, BW's, X-Max 125 ') 

$sqldata = $wpdb->query("INSERT INTO `wp_make_details`  
         (`c_id`, `post_id`, `make_name`, `year`, `model_name`) 
         values (NULL,".$post_id.",'".$all_make."', '".$all_year."', '". $all_model."')"); 

回聲查詢結果,我不知道還發生了什麼不知道爲什麼錯誤到來MariaDB,我在谷歌發現,但我不能讓解決方案。

有人知道嗎幫助我嗎?

+0

是不是這個「c_id」和uto_increment? –

回答

0

最後我解決了這個問題,我錯過了mysql_real_escape_string()

,並通過使用此我完成查詢

$sqldata = $wpdb->query("INSERT INTO `wp_make_details`  
          (`c_id`, `post_id`, `make_name`, `year`, `model_name`) 
          values (NULL,".$post_id.",'".$all_make."', '".$all_year."', '".mysql_real_escape_string($all_model)."')"); 

現在正在完善。