Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tislam's avatar

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

I just add my laravel project in my cpanel but when I try to add it's showing an error. SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' (SQL: insert into appointments (full_name, phone_number, additional_information, email, department, date_and_time, updated_at, created_at) values (ss, 01754890543, i need help for indian tretment, [email protected], 1, 2019/12/23 22:40, 2019-12-27 08:16:40, 2019-12-27 08:16:40)) it's working fine in localhost but showing this error after adding it to live server.

0 likes
4 replies
Nakov's avatar
Nakov
Best Answer
Level 73

Do you have AUTOINCREMENT on your primary keys? You ran php artisan migrate on your production server or you imported a database from somewhere else?

1 like
Snapey's avatar

did you use migrations to create your database tables? It seems like autoincrement of the id is not working

tislam's avatar

thnks, its working now. but I'm not sure how it is. because i export from localhost sql file this server. i only chang 'strict' => false,

Nakov's avatar

@tislam it happens that the autoincrement is not retained when you export from one database to another.

1 like

Please or to participate in this conversation.