SELECT * FROM images im 	LEFT JOIN images_text it ON it.image_id = im.id 	WHERE im.page_id =  ORDER BY im.main

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 'ORDER BY im.main' at line 1

file -
line -