lerro,
The problem seems to be that you have an integer as the datatype for the column that you are trying to use such a LONG unique key.
I Suggest one of two things:
1) Use the auto_increment field and set an auto_increment value of 10000 or 100000 (or something random in there) if you don't expect a HUGE database of rows. (the higher you go the lower the possible number of entries)
lerro wrote:
Duplicate entry '2147483647' for key 'PRIMARY'
Take a look at that number
A normal-size integer. The signed range is -2147483648 to 2147483647
This is from the MySQL Docs.
You will notice they are the same! That's because as rulian pointed out that the number should be 18 char's long, WELL beyond the scope of a signed int.
When a number is provided that goes beyond the boundry of a numeric type, MySQL will assume the highest possible number, since it was already entered once, it tries again and gets a duplicate entry.
If you want to use your current method of creating a unique/primary key (as it seems you are doing) you must change the datatype to BIGINT
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.
Again from MySQL Docs, you will notice that there are points to keep in mind when using unsigned bigint's, speficially not to go larger than 63 bits (9223372036854775807)
Please let me know if you have any further questions.