Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

getting SQL syntex Error


sinryder

Recommended Posts

hello guys i am trying to add a search by model feature in admin-categories/products (search box) currently it only searches by name

 

here is what i am changing

 

admin/categories.php

 

from this

 

 

      $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

 

to this

 

 

      $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' or p.products_model like '%" . tep_db_input($search) . "%') order by pd.products_name");

 

 

and when i try the search now this is what i get

 

 

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 ') order by pd.products_name' at line 1

 

select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from products p, products_description pd, products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and pd.products_name like '%account report%' or p.products_model like '%account report%') order by pd.products_name

 

 

can any one please help me fix this problem

 

thankyou

Link to comment
Share on other sites

hello guys i am trying to add a search by model feature in admin-categories/products (search box) currently it only searches by name

 

here is what i am changing

 

admin/categories.php

 

from this

 ? ? ?$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

 

to this

 ? ? ?$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' or p.products_model like '%" . tep_db_input($search) . "%') order by pd.products_name");

and when i try the search now this is what i get

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 ') order by pd.products_name' at line 1

 

select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_retail_price, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from products p, products_description pd, products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and pd.products_name like '%account report%' or p.products_model like '%account report%') order by pd.products_name

can any one please help me fix this problem

 

thankyou

 

 

don't use the closing bracket if you don't open one :

 

tep_db_input($search) . "%')

Treasurer MFC

Link to comment
Share on other sites

don't use the closing bracket if you don't open one :

 

tep_db_input($search) . "%')

 

 

hey thankx for the quick reply,

the error is gone now, but its taking for ever to search. I hit the search button almost 5 min ago and its still searching. like the explorer green status bar still is in the middle. Can you tell me if their is anything wrong with the above code to make this search better

 

thankyou

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...