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 '' at line 1select subject1.id, class.class_name, subject1.subject_name from subjects AS subject1, mmg_classes AS class where subject1.class_id = class.id and subject1.publish = 1 and subject1.class_id = 3 and subject1.id =