I have a databse problem where i get Integrity constraint violation: 1062. I tried some things on my own but it didtn work so now i am asking you guys to see if you people can h
I had the same problem, and it was not the auto increment that was causing it. I changed the data type on my table ID from TINYINT(3)
to INT(10)
. Try that. Maybe it'll help.
When inserting into a table with an auto increment field, the auto increment field itself should not be specified at all.
Query("INSERT INTO prod_categorie (categorieID, parentID) VALUES (?, ?)", array($chkParent, $txtParentCategorie));
^^^^^^^^^^^ ^ ^^^^^^^^^^
Should be just
Query("INSERT INTO prod_categorie (parentID) VALUES (?)", array($txtParentCategorie));
Just added as answer from comment discussion to allow accept and finishing the question.
I came across this problem when using Magento 2 with the Google Experiment set to Yes. Simply shutting it off solved my page save issue. Bu ti'm still having a problem with adding catalog products it give me an error that the URL Key for the specified store already exists. and the image is not uploading even though i have correct folder permissions. Will post an update in case it helps anyone else.
in my case the error is:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'
the solution is to Empty/Truncate all records of the table in question
The problem happens when auto-increment is disabled on the primary-key of that table or the data-type is wrong.
partially credited to https://magento.stackexchange.com/questions/56354/admin-error-sqlstate23000-integrity-constraint-violation-1062-duplicate-ent