SELECT id, name, permalink, representative_picture_id, comment, nb_images, uppercats, date_last, max_date_last, count_images, count_categories FROM phpwebgallery_categories INNER JOIN phpwebgallery_user_cache_categories ON id = cat_id and user_id = 2 WHERE id_uppercat is NULL ORDER BY rank ; [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 '' at line 8