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 aktywny="Y" order by pozycja' at line 2
SELECT t1.id as id, parent_id, lang_id, img_list, zdjecie2, pozycja, aktywny, usuniety, aliasy_id, nazwa, alias, nazwa_grupy_podkategorii, tytul, opis, sl_klucz
FROM sk_kategorie_info t1 where usuniety = 'N' and (lang_id = 6 or lang_id = NULL ) and and aktywny="Y" order by pozycja