Database Error: 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 'or (ai.sortorder = and i.id <))
order by ai.sortord' at line 10
From:select a.name as albumname,a.siteurl,i.status,i.path,i.audiopath,i.name,
i.keywords,i.description,i.exif,i.date_addition,i.views,ai.sortorder,i.type,
i.date_picture,i.id as imageid
from album a, albumimage ai, image i
where ai.albumid=a.id
and ai.imageid=i.id
and i.status = 'active'
and a.id =636
and (ai.sortorder <
or (ai.sortorder = and i.id <))
order by ai.sortorder desc, i.id limit 1