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 'on%' OR LOWER(description) LIKE '%uni/**/on%' OR LOWER(brief_description) ' at line 1 SQL query : SELECT COUNT(DISTINCT p.productID) FROM SS_products p where categoryID>1 and enabled=1 and ( LOWER(name) LIKE '%panason''%' /* OR LOWER(product_code ) LIKE '%panason''%' OR LOWER(description) LIKE '%panason''%' OR LOWER(brief_description) LIKE '%panason''%' */) AND ( LOWER(name) LIKE '%and%' /* OR LOWER(product_code ) LIKE '%and%' OR LOWER(description) LIKE '%and%' OR LOWER(brief_description) LIKE '%and%' */) AND ( LOWER(name) LIKE '%sleep(3)))%' /* OR LOWER(product_code ) LIKE '%sleep(3)))%' OR LOWER(description) LIKE '%sleep(3)))%' OR LOWER(brief_description) LIKE '%sleep(3)))%' */) AND ( LOWER(name) LIKE '%uni/**/on%' /* OR LOWER(product_code ) LIKE '%uni/**/on%' OR LOWER(description) LIKE '%uni/**/on%' OR LOWER(brief_description) LIKE '%uni/**/on%' */) AND ( LOWER(name) LIKE '%sel/**/ect%' /* OR LOWER(product_code ) LIKE '%sel/**/ect%' OR LOWER(description) LIKE '%sel/**/ect%' OR LOWER(brief_description) LIKE '%sel/**/ect%' */) AND ( LOWER(name) LIKE '%1,2,3,4,5,6,7,8,9,10%' /* OR LOWER(product_code ) LIKE '%1,2,3,4,5,6,7,8,9,10%' OR LOWER(description) LIKE '%1,2,3,4,5,6,7,8,9,10%' OR LOWER(brief_description) LIKE '%1,2,3,4,5,6,7,8,9,10%' */)