The error is because their is no specification for the 'ORDER BY'... should be between the 'ORDER BY' and the 'LIMIT 0,1' - so a variable isn't properly populated...
You didn't proved a link to your gallery - nor the version/release you are running - s...
You didn't proved a link to your gallery - nor the version/release you are running - s...