$mess=mysql_query("SELECT DISTINCT mittente, username
FROM t_messaggi_privati, t_utenti
WHERE mittente = userID
AND mittente = $mittente
ORDER BY $result DESC");
1)in questa query non ho capito il senso di mittente = userID e mittente = $mittente.
2) mysql_result è deprecata come riportato nel manuale e non dovresti utilizzarla.
3) non so come sia strutturata la tua tabella ma magari basta una query così
select mittente,count(mittente) as messaggi
from t_messaggi_privati
group by mittente
order by messaggi desc