Jump to content

Duplicate ID


yandoo

Recommended Posts

Hi there,

 

I just run into a little problem and was hoping for a little advice.

 

I have a table in my database that has a INT AutoIncrement function as primary key ....

 

When i insert new records thought my php page i assign the Primary key of the Record by totaling the records currently and adding 1.

E.G:

<?php echo $totalRows_record +1 ?>

 

Heres the problem....

 

If i have say 10 records in the table and i delete record number 9 then when i try to INSERT another record i get error message DUPLICATE Primary Key! And thats because the query i am using is totaling the number of records i.e. 9 (after deleting record 9)....

 

How can I overcome this please???

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/98536-duplicate-id/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.