Note: Because mysql_insert_id() acts on the last performed query, be sure to call mysql_insert_id() immediately after the query that generates the value.

hai proprio bisogno di una funzione a parte per ricavare l'id, per una riga di codice?
cmq vedi anche last_insert_id