Thomisback Posted August 2, 2008 Share Posted August 2, 2008 Hi, I get an error when executing my query but I don't get why, can someone please correct me? $title = "Thomisback"; mysql_query("INSERT INTO `cscart_product_descriptions` (`product_id`, `lang_code`, `product`, `shortname`, `short_description`, `full_description`, `meta_keywords`, `meta_description`, `search_words`, `page_title`) VALUES ($productid, 'EN', '$title', '', '', '', '$title', '$title', '$title', '$title'), ($productid, 'NL', '$title', '', '', '', '$title', '$title', $title'', '')")or die(mysql_error()); The error I get: 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 ''', '')' at line 3 Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 2, 2008 Share Posted August 2, 2008 Make your life easier and create your query as a variable so you echo it to the page when an error occurs: <?php $title = "Thomisback"; $query = "INSERT INTO `cscart_product_descriptions` (`product_id`, `lang_code`, `product`, `shortname`, `short_description`, `full_description`, `meta_keywords`, `meta_description`, `search_words`, `page_title`) VALUES ($productid, 'EN', '$title', '', '', '', '$title', '$title', '$title', '$title'), ($productid, 'NL', '$title', '', '', '', '$title', '$title', $title'', '')"; mysql_query($query) or die ("Query:<br />$query<br />Error:<br />".mysql_error()); ?> You would probably then see that the error is at the very end of the query: ($productid, 'NL', '$title', '', '', '', '$title', '$title', $title'', '') There's a missing comma. Quote Link to comment Share on other sites More sharing options...
Thomisback Posted August 2, 2008 Author Share Posted August 2, 2008 Thanks a lot for the hints, I solved it using your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.