While working on a php insert-record form I was getting the error:

#1062 - Duplicate entry '127' for key 1 

although there were no other records with the id “127” – just the latest one.

Thanks to jc_armor for the answer to this:
“quick question, what’s the Data Type of your ID field? It could be a reason that the data type can only handle up to 127 🙂 “

Changing the field type to “unsigned INT” as recommended in the forum message made the error disappear.

MySQL Reference Manual: data types: numeric types