You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and fap_exhibit_images.im_id=fap_images.i_id and fap_exhibit_images.ex_id=fap_' at line 4