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 l.PART_id>0 AND l.LOCA_blocked != 1 AND l.LOCA_img_small AND l.LOCA_img1 AND' at line 1