In php have a form with a textarea and a file upload. In mysql I have table 1 with rows for each uploaded file having data like name, size, etc… and I have table 2 with the data entered in the textarea and a column with the id of the file uploaded.
I’m using mysql_insert_id to get the id of the last inserted row in table 1 (the id of file uploaded). Then I insert that id in table 2.
Assuming that multiple uploads are made at the same by different users will mysql_insert_id return the proper id each time? What happens if 2 users upload at the exact time.. Or there is a timeout.. I guess I’m asking if there’s a better way to insert a newly created id to 2 tables at the same time?
It returns the id of inserted row for the session from which the insert has been made. So yes, you’re doing it just fine.