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 (t1.data_od <= NOW() OR t1.data_od='0000-00-00 00:00:00') AND (NOW() <= t1.d' at line 4

SELECT t1.*, t2.nazwa nazwa_obrazu, t2.nazwa_pliku FROM `strona_wpisyex` t1 LEFT JOIN `strona_wpisy_repozytorium` t2 ON t1.id=t2.id_wpisy AND t2.pozycja=1 WHERE id_kategorii= AND (t1.data_od <= NOW() OR t1.data_od='0000-00-00 00:00:00') AND (NOW() <= t1.data_do OR t1.data_od='0000-00-00 00:00:00') ORDER BY t1.pozycja ASC