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 'ORDER BY s.sort_index' at line 14
SELECT s.*, s.name as name, s.descr_shot as descr_shot, s.html as html, s.html_section as html_section, s.page_name as page_name, s.name as name, s.description as description, s.title as title FROM states_content s WHERE s.status = 1 AND s.page_name_friendly_url = 'important' AND s.state_id = ORDER BY s.sort_index