fai così:

Codice PHP:
$result mysql_query("SELECT MAX(id) AS maxid FROM `profili`");
$mydata mysql_result($result0);