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 '?) and cd.language_id='1' and c.categories_status='1' order by c.sort_order,cd.c' at line 1
in:
[select distinct c.categories_id, cd.categories_name, cg.master_categories_id from categories c, categories_description cd, products cg, products_size ps, (SELECT DISTINCT master_categories_id FROM (SELECT 1-s.specials_new_products_price/p.products_price as discount, p.products_id, p.products_sx_id, p.master_categories_id, COUNT(DISTINCT products_sx_id),IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price FROM products p left join specials s on p.products_id = s.products_id GROUP BY products_sx_id) psx WHERE psx.discount > 0.2) jx where c.categories_id=cd.categories_id and cg.master_categories_id=c.categories_id and jx.master_categories_id=c.categories_id and ps.products_size like '%~M~%' and ps.products_size not like '%M NO%' and cg.products_size_id = ps.products_size_id and c.categories_id IN(50
) and cd.language_id='1' and c.categories_status='1' order by c.sort_order,cd.categories_id]