Depends on what you want to do with the id, and if more than one person can be doing an insert at the same (or almost same) time.
The query "SELECT MAX(id) FROM table" doesn't guarantee you get the id of the row you just inserted (but that is not what you asked).