Re: Getting last record ID created from DB

From: Date: Sat, 17 Mar 2007 03:37:33 +0000
Subject: Re: Getting last record ID created from DB
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250740@lists.php.net to get a copy of this message
On Fri, 16 Mar 2007 22:28:54 -0500 "Jeff" <akaman@akaproz.com> wrote: > Is there a way to get the last Record # created by the DB. > > > $query = "INSERT INTO t_users > (user_id, f_name, > l_name, > e_mail, b_date, > pic) VALUES ('', '$f_name', '$l_name', > '$e_mail', '$b_date', '')"; > $result = mysql_query($query); > if(!$result) > { > die("Could not query the database: <br/>".mysql_error()); > } > echo "Your Player information has been stored OK.<br />"; > > what code could I add here to make the following line work? > > echo "REMEMBER your USER ID# you will need it when creating > Characters!! It is: $user_id"; <----- I want to show the "user_id" > just created here. > > Thanks in advance! > select user_id from t_users where user_id = (select max(user_id) from t_users) -- Rod ----- Empty your mind, be formless, shapeless like water. Now you put water into a cup and it becomes the cup. You put water in a bottle it becomes the bottle. You put it into a teapot it becomes the teapot. Now water can flow or it can crash. Be water, my friend. -- Bruce Lee

Attachment: [application/pgp-signature] signature.asc
« previous php.general (#250740) next »