joe92 Posted January 12, 2012 Share Posted January 12, 2012 An admin of a site I am creating needs to be able to create members with certain extra authorities, moderators if you will. They will create the members and insert all the details. However, they also need to keep paper records of these moderators with all the details on them. On these paper records is included the ID of the moderator. So I wish to display on screen after the member has been created, the members ID so the admin can make a note of it. This is the query being used (shortened): $new = mysql_query("INSERT INTO members (ID, name) VALUES (NULL, '$name')"); Without again querying the database am I able to find out what the value of the newly created ID is, that NULL value? Google has revealed nothing so far. Thanks for any help, Joe Quote Link to comment https://forums.phpfreaks.com/topic/254881-insert-into-auto-increment-and-remember-the-value/ Share on other sites More sharing options...
Muddy_Funster Posted January 12, 2012 Share Posted January 12, 2012 ok, you don't insert anything into an auto inc filed - EVER. You can't retrieve a resultset from running an INPUT statement. If you want information out of the database you are going to need to run a SELECT on it, so you will need another query. Quote Link to comment https://forums.phpfreaks.com/topic/254881-insert-into-auto-increment-and-remember-the-value/#findComment-1306886 Share on other sites More sharing options...
PFMaBiSmAd Posted January 12, 2012 Share Posted January 12, 2012 mysql_insert_id Quote Link to comment https://forums.phpfreaks.com/topic/254881-insert-into-auto-increment-and-remember-the-value/#findComment-1306888 Share on other sites More sharing options...
joe92 Posted January 12, 2012 Author Share Posted January 12, 2012 Twice in two days you've solved my problems . That is a cracking function, does exactly what I need, thanks PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/254881-insert-into-auto-increment-and-remember-the-value/#findComment-1306893 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.