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 a.id_categoria=12 AND a.scadenza>'2021-07-31 00:51:42' AND a.pubblica=3 AND ' at line 3