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 'WHERE attivo='1' AND id_comune IN(1,5,4,2,3,'') AND tipologia='' ORDER BY RAND()' at line 1