is right (no surprises there) about LAST_INSERT_ID. If I read you right, though, your (reasonable) concern is that between making the new db entry and getting the ID, somebody else makes a new entry and you end up getting the wrong ID. This is something I asked about a while back, and
has some interesting discussion. NB that if, as I am told, more recent versions of MYSQL support transactions, then there is a more elegant way to solve the problem than
work.