Jump to content

Mysql Syntax Error?? PHP code error?


jcorrea920

Recommended Posts

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

Link to comment
Share on other sites

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.

 

;D

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.