mi sono letto un attimo i commenti su php.net riguardo questa funzione, e forse la soluzione migliore che ti da la massima sicurezza è questa:
codice:
Have had many people coming to me with issues regarding last_insert_id and mysql_insert_id() etc
This is a very simple solution that caters for most. As you can see it gets the last auto inc from the field, in this case, ID.
mysql_query("LOCK TABLES art WRITE");
mysql_query("INSERT INTO table (....) VALUES (....)");
$result = mysql_query("SELECT MAX(ID) AS LAST_ID FROM table");
$result = mysql_fetch_array($result);
mysql_query("UNLOCK TABLES");
echo "Last ID#" . $result[LAST_ID];
anche perchè leggevo che mysql_insert_id restituisce valori errati in caso di indice autoincrement se questo è di tipo BIGINT.
ciao