On Fri, March 16, 2007 10:28 pm, Jeff wrote:
> Is there a way to get the last Record # created by the DB.

Yes, but...

> Example:
>
> User_ID = auto_increment
> f_name = varchar
> l_name = varchar
> e-mail = varchar
> b_date = varchar
> pic = varchar
>
>
> Since user_id is an auto_inc field I submit it as a NULL, also I
> haven't
> started the code for a picture yet either so I have it set to NULL at
> this
> moment.
> My code is:
>
> $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.

What you think you want is this function:
http://php.net/mysql_insert_id

You REALLY shouldn't do this in this case, for several reasons.

#1.
Never expose an internal ID to the end user as if it had meaning.
There are several reasons for this, ranging from security to data
integrity, and there are times to break this rule, but you're not in
one of those situations.

#2.
Don't make me remember some stupid number.  That's just Bad User
Interface.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to