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 1 - SELECT count(iid) as total FROM VCD WHERE on_cat =1 AND full_mp4_online =1 AND Num_of_Files_MP4 >=1 and iid = ;