Ошибка в SQL:

SELECT * FROM images WHERE pid = 115 AND module_id = 1 ORDER BY sort, id LIMIT 0,