1

I got a error during inserting data into MySql Database.

data are inserted successfully but with given error [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] '

following query i used for inserting record in database.

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

echo query result with values like

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

i don't know what happen also don't know why error is coming of MariaDB, i found in google but i can not get solution for this.

is anyone know about it help me please ?

1
  • isn't this "c_id" and uto_increment ? Commented Nov 11, 2016 at 11:40

1 Answer 1

1

Finally i resolved this issue i missed mysql_real_escape_string()

and by using this my completed query is

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

And now is working perfect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.