Jump to content

mysql error - Duplicate Key 1


freakus_maximus

Recommended Posts

Here's an odd one...hoping someone has run into this and may have a clue...

If I start with an empty table (my "id" field is set to autoincrement and is the primary key) any updates I do with my form all work just fine.

But, if I import (through phpMyAdmin) a data file and fill in the table and then later try and do an update through my form I get a duplicate key 1 error.

My form handles checking for existing "defectnumber" and the table does not allow duplicates on that field.

I went back and emptied the table again just to check and my updates work fine from the form.

Any ideas what could be the problem that only after importing I get a duplicate key 1 error?
Link to comment
Share on other sites

try importing the data, then removing the primary key and try to insert data into the table... could it be that when you import this data file it isn't updating the position for the unique ID that you use? so after importing its still trying to dump it in at 1 when 1 already exists?

You could also try setting your id value to a number you know isno't already in the table to see if that still causes the error.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.