Hi Guys,

I am trying to add an entry into the mysql database. All has been working well for ages and then suddenly, I have started to get this error message:

"MySQL said: Duplicate entry '127' for key 1 "

What does it mean? Have I set my database up wrong or have I run out of space?

Any help or pointers would be gratefully recieved.

Cheers,

Jimbob

    that means that a column indexed as either unique or the primary key (probably the primary key since it's key 1) is being duplicated.

    In other words, a field already has the value 127 in it and you're trying to put 127 into it again. This normally is not a problem but it's indexed as unique or primary.

      Thanks. Problem solve. It was trying add an entry with identical primary keys.

      I had set the primary key to auto-increment and so had discounted this option. However, I made a mistake in setting up the TYPE for the primary key field. It had run out of numbers left to count. It was at number 127 and this is the top number for TINYINT. I have now set the field TYPE as MEDIUMINT and all is working again.

      Thanks,

      Jimbo

        I ALWAYS use bigint for auto incrment primary key fields. It's overkill in most cases, but I have yet to have it run out of numbers.

          24 days later

          iam doing update with exciting data and i get same error

            Write a Reply...