digital01 Posted August 28, 2006 Posted August 28, 2006 I just recently downloaded the contribution to view new products by month and i'm getting the following 1064 sql error. 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 'select p.products_id, pd.products_name, pd.products_description, p.products_imag' at line 1 select count(select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, p.products_date_available, m.manufacturers_name from products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join products_description pd on p.products_id = pd.products_id and pd.language_id = \'1\' left join specials s on p.products_id = s.products_id \r\n where p.products_date_available >= \'2006-06-01 00:00:00\' AND p.products_date_available < \'2006-7-01 00:00:00\'\r\n order by p.products_date_available DESC, pd.products_name) as total [TEP STOP] The contribution was made in 2002, so I presume that the code was written with either mysql 3.xx or mysql 4 compatibility. I'm currently running MySql 5.0 and I can't seem to figure out whats wrong with the following part of code: <?php $search_mon = ($HTTP_GET_VARS['month_id']); $search_year = ($HTTP_GET_VARS['year_id']); if (strlen ($search_mon) == 1) $start_month = ("0" . $search_mon); else $start_month = $search_mon; $end_month = ($start_month + 1); $start_year = (date("Y")+$search_year); $end_year = (date("Y")+$search_year); if ($end_month == 13) { $end_month = 01; $end_year = (date("Y") +1); } $start_date = ($start_year . "-" . $start_month . "-01" . " 00:00:00"); $end_date = ($end_year . "-" . $end_month . "-01" . " 00:00:00"); $products_new_query_raw = "select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, p.products_date_available, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_date_available >= '$start_date' AND p.products_date_available < '$end_date' order by p.products_date_available DESC, pd.products_name"; $products_new_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_PRODUCTS_NEW, $products_new_query_raw, $products_new_numrows); $products_new_query = tep_db_query($products_new_query_raw); while ($products_new = tep_db_fetch_array($products_new_query)) { $products_new_array[] = array('id' => $products_new['products_id'], 'name' => $products_new['products_name'], 'description' => $products_new['products_description'], 'image' => $products_new['products_image'], 'price' => $products_new['products_price'], 'specials_price' => $products_new['specials_new_products_price'], 'tax_class_id' => $products_new['products_tax_class_id'], 'date_added' => tep_date_long($products_new['products_date_available']), 'manufacturer' => $products_new['manufacturers_name']); } require(DIR_WS_MODULES . 'products_by_mon.php'); ?> If anyone could help me with finding out the compatibility differences in the above code, it would be much appreciated. The contribution is located at: http://www.oscommerce.com/community/contri...+products+month Quote
digital01 Posted August 30, 2006 Author Posted August 30, 2006 I've narrowed it down to the following code: $products_new_query_raw = "select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, p.products_date_available, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_date_available >= '$start_date' AND p.products_date_available < '$end_date' order by p.products_date_available DESC, pd.products_name"; $products_new_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_PRODUCTS_NEW, $products_new_query_raw, $products_new_numrows); Anyone see anything wrong with this for mysql5? Quote
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.
Note: Your post will require moderator approval before it will be visible.