Error 1064: Error in query "SELECT * FROM ppp_photo WHERE gallerytree_id = 4; ORDER BY photo_id" 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 'ORDER BY photo_id' at line 1