Bad query: sql_get_album_images - SELECT i.img_id, filename, title, notes, img_h, img_w, price, price_mounted, price_framed, edition, num_sold, img_page_filename FROM images as i, albums as a, album_contents as c, users as u WHERE img_visibility = 1 AND a.album_id = AND c.album_id = a.album_id AND i.img_id = c.img_id AND u.user_id = i.user_id AND ( status = 'A' OR status = 'U' ) ORDER BY display_order ASC, alb_content_updated DESC LIMIT 0, 1 . 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 'AND c.album_id = a.album_id AND i.img_id = c.img_id AND u.user_id = i.user_...' at line 16