did first db query in gallery.php