shadiadiph Posted March 23, 2009 Share Posted March 23, 2009 how do i get the value of the last id inserted into the database again sorry i have forgotten Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 23, 2009 Share Posted March 23, 2009 i pulled this out which has worked for me //get the ID of the most recent addition to the table $sql = mysql_query("SELECT SCOPE_IDENTITY() AS [sCOPE_IDENTITY]"); $row = mysql_fetch_array($sql); $newID = $row['SCOPE_IDENTITY']; Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 23, 2009 Share Posted March 23, 2009 Well, personally, i would just use the command that is already built into the application: mysql_insert_id() http://us.php.net/mysql_insert_id mysql_insert_id mysql_insert_id — Get the ID generated from the previous INSERT operation OR, if you need to use it in a query: $query = "UPDATE table SET foo = 'bar' WHERE id = LAST_INSERT_ID()"; Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted March 24, 2009 Author Share Posted March 24, 2009 mm ok thanks i shall try it later need to get some sleep first Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.