Error: Duplicate entry ‘0’ for key ‘PRIMARY’

For those arriving at this question because of the question title (as I did), this solved my problem:

This error can indicate that the table’s PRIMARY KEY is not set to AUTO-INCREMENT, (and your insert query did not specify an ID value).

To resolve:

Check that there is a PRIMARY KEY set on your table, and that the PRIMARY KEY is set to AUTO-INCREMENT.

How to add auto-increment to column in mysql database using phpmyadmin?

Leave a Comment