Small clarification;
mysql_insert_id() reports the insert_id of the last insert that was executed on
the selected database connection.
So if you close the database connection, you loose the insert_id.
If you execute another insert, you loose the old insert_id.
But, if you open a connection, do an insert, include() another script, pass the database connection identfied to a function in the included script, that function can read the insert_id.