如果在我调用之前发生另一个autoIncrement,msql_insert_id()会给我一个不正确的结果吗?

I'm trying to add a row to a table, and then immediately get its unique ID, which is simply an autoincremented column.

Googling tells me PHP can do this through the mysql_insert_id() method, which

Retrieves the ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).

Is the "previous query" limited in scope to this specific connection, or is it possible that if somehow another row is inserted before I call it, it will return the wrong ID?

Are there any better suggestions on how to get or set a unique ID for a row? I'd make the unique ID on the client-side, but there are multiple clients, so that's not really possible.

Thanks.

Yes, it's limited to connection, so it will return a reliable value.

Try to use mysqli-functions or PDO, MySQL will be deceprated.