Hi,

Your are using LAST_INSERT_ID wrong. You should just do:

insert into player_table(player_name) values ('$player_name');

And then use LAST_INSERT_ID to find out what player_id was assigned.

Although "LAST_INSERT_ID() + 1" will give you "your last value +1", another
client might already have used that value.

Regards

Quentin


-----Original Message-----
From: Doug Linley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 20 February 2001 11:33
To: [EMAIL PROTECTED]
Subject: auto_increment and last_insert_value()


I have a table that I created that has a primary key field that should be
auto_incremented.  To fill in this value I am calling

insert into player_table(playerid, player_name) values (LAST_INSERT_ID() +
1, '$player_name');

My problem is that I'm getting duplicated key values because last_insert_id
is always 0.  Anyone know what the problem might be?  The field is indexed
by the way.

Thanks in advance for your help!

Doug L.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

The information contained in this email is privileged and confidential
and intended for the addressee only. If you are not the intended 
recipient, you are asked to respect that confidentiality and not 
disclose, copy or make use of its contents. If received in error 
you are asked to destroy this email and contact the sender immediately. 
Your assistance is appreciated.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to