Warning: [mysql error 1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC' at line 7

SELECT DISTINCT(image_id)
  FROM piwigo_image_category
    INNER JOIN piwigo_images ON id = image_id
  WHERE
    category_id = 178
AND (category_id NOT IN (619,658))
   ORDER BY rank ASC
; in /home/ortolan/public_html/grzyby/include/dblayer/functions_mysqli.inc.php on line 847
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean in /home/ortolan/public_html/grzyby/include/dblayer/functions_mysqli.inc.php:908 Stack trace: #0 /home/ortolan/public_html/grzyby/include/section_init.inc.php(317): query2array('\nSELECT DISTINC...', NULL, 'image_id') #1 /home/ortolan/public_html/grzyby/index.php(12): include('/home/ortolan/p...') #2 {main} thrown in /home/ortolan/public_html/grzyby/include/dblayer/functions_mysqli.inc.php on line 908