Select * from package_photos where is_active = 1 and package_id = and file_type = 'Photo' 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 file_type = 'Photo'' at line 1