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 images.img_type = 1 AND images.img_default = 1 AND images.img_propid = sales' at line 1