INSERT new row and MKDIR with the name of that inserted row ID

vorrax

New Member
The page has to INSERT a row and MAKE a directory with the name of the ID of that row when the user clicks the upload button, will this script work?, what could possibly go wrong?.\[quote\] (when the upload button has been clicked)
//insert the new row
$query="INSERT INTO photoalbum (userid) VALUES ($userid)";
mysql_query($query); //get the id of that row to make a directory with that name
$getid="SELECT id FROM photoalbum WHERE userid = $userid order by id desc limit 1";
$result=mysql_query($getid);
$thename=mysql_results($result,0,"id");
mkdir('userimages/$userid/photoalbums/$thename'); { script that upload the files in the new folder }\[/quote\]Is it safe to INSERT and SELECT the row I just inserted in the same page, just right after an insert has been done? I was thinking what if the SELECT query don't pick the row i just inserted but instead the previous row, because the INSERT isnt fast enough and the SELECT query gets the previous row instead. Is this a possible scenario?
 
Back
Top