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 Link to comment https://forums.phpfreaks.com/topic/117836-solved-you-have-an-error-in-your-sql-syntax/ 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. Link to comment https://forums.phpfreaks.com/topic/117836-solved-you-have-an-error-in-your-sql-syntax/#findComment-606088 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! Link to comment https://forums.phpfreaks.com/topic/117836-solved-you-have-an-error-in-your-sql-syntax/#findComment-606099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.