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 '' at line 9SELECT COUNT(DISTINCT med_titre) resultat FROM media JOIN media_lien ON mel_med_id=med_id AND mel_tablecible='annuaire_entree' JOIN annuaire_entree ON aen_id=mel_cible_id WHERE med_mtm_id=2 AND (med_filename like '%mp3%' OR med_filename like '%wav%') AND mel_cible_id=