【问题标题】:Error during insert data in mysql WordPress database error?在 mysql WordPress 数据库中插入数据时出错?
【发布时间】:2016-11-11 11:23:24
【问题描述】:

在将数据插入MySql 数据库时出错。

数据插入成功,但出现错误[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] '

以下查询我用于在数据库中插入记录。

$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."')");

使用类似的值回显查询结果

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 ')

我不知道发生了什么也不知道为什么MariaDB 会出现错误,我在 google 中找到了,但我无法得到解决方案。

有人知道吗,请帮帮我?

【问题讨论】:

  • 这不是“c_id”和uto_increment吗?

标签: php mysql wordpress


【解决方案1】:

最后我解决了这个我错过了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)."')"); 

现在运行完美。

【讨论】:

    猜你喜欢
    • 2016-08-23
    • 1970-01-01
    • 2013-04-25
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多