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 tbll.id_lang=2 AND datefrom<="2012-05-28" AND dateto>="2012-05-28") OR' at line 4

		SELECT tb.color, tb.width, tb.height, tb.opacity, tbll.description, tb.display, tb.mode     
		FROM (bt_ca_category_page tb INNER JOIN bt_ca_category_page_category tbl ON
		(tb.id_page=tbl.id_page)) INNER JOIN bt_ca_category_page_lang tbll ON 
		(tb.id_page=tbll.id_page) WHERE (tb.active=1 AND tbl.id_category= AND tbll.id_lang=2 
		AND datefrom<="2012-05-28" AND dateto>="2012-05-28") 
		OR (tb.active=1 AND tbl.id_category= AND tbll.id_lang=2 
		AND datefrom="0000-00-00" AND dateto="0000-00-00")