jcorrea920 Posted August 6, 2007 Share Posted August 6, 2007 Hello, I am using mysql for a web application and I continue to get the following error in syntax: 1064 - 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 '' limit 0, 8' at line 1 select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, p.manufacturers_id from products p, products_description pd where date_sub(curdate(),interval 30 day) <= p.products_date_added and p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '1' order by p.products_date_added desc, pd.products_name' limit 0, 8 The code for that particular line is: $new_products_query = tep_db_query("select distinct p.products_id, p.products_price, p.products_tax_class_id, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where DATE_SUB(CURDATE(),INTERVAL " . NEW_PRODUCT_INTERVAL . " DAY) <= p.products_date_added and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $new_products_category_id . "' and p.products_status = '1' order by p.products_date_added DESC limit " . MAX_DISPLAY_NEW_PRODUCTS); I am currently using MySQL 5.0.22 for Fedora Core 6. I am just a newbie and have triple checked the code and compared to all other sql queries on the other pages it seems to be alright. what am I missing? Any help would be greatly appreciated. Jorge Quote Link to comment https://forums.phpfreaks.com/topic/63626-mysql-syntax-error-php-code-error/ Share on other sites More sharing options...
hvle Posted August 7, 2007 Share Posted August 7, 2007 what is tep_db_query? should you use mysql_query() instead? Quote Link to comment https://forums.phpfreaks.com/topic/63626-mysql-syntax-error-php-code-error/#findComment-317118 Share on other sites More sharing options...
hitman6003 Posted August 7, 2007 Share Posted August 7, 2007 you have a rogue single quote here: sc, pd.products_name' limit 0, 8 Remove it from your query. Quote Link to comment https://forums.phpfreaks.com/topic/63626-mysql-syntax-error-php-code-error/#findComment-317167 Share on other sites More sharing options...
jcorrea920 Posted August 7, 2007 Author Share Posted August 7, 2007 Sorry but the error was in another section of code. I was looking in the wrong place! :-\ The Code is: $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where DATE_SUB(CURDATE(),INTERVAL " [i][b][font=Verdana].NEW_PRODUCT_INTERVAL .[/font][/b][/i]" DAY) <= p.products_date_added and p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; The correction was simply adding a space .NEW_PRODUCT_INTERVAL . to . NEW_PRODUCT_INTERVAL . Thanks for all your suggestions. Great help. Quote Link to comment https://forums.phpfreaks.com/topic/63626-mysql-syntax-error-php-code-error/#findComment-317755 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.