I've never once had a problem with last_insert_id. As a previous poster mentioned, it's per connection. Relevant quote from the docs below. There's also a note about SQL function LAST_INSERT_ID() if you happen to use it.
From http://dev.mysql.com/doc/mysql/en/mysql_insert_id.html
Note that mysql_insert_id() returns 0 if the previous statement does not use an AUTO_INCREMENT value. If you need to save the value for later, be sure to call mysql_insert_id() immediately after the statement that generates the value.
The value of mysql_insert_id() is affected only by statements issued within the current client connection. It is not affected by statements issued by other clients.