Codice PHP:
$query "SELECT count(*) 
          FROM messaggio 
          where cod_associato = '"
.$cod."'"
$query_count mysql_query($query) or die (mysql_error());

$count mysql_fetch_row($query_count);
                                                                                               
if (
$count[0] == 0) {
     echo 
'ciao';