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

tislam's avatar

General error: 1364 Field 'id' doesn't have a default value after hosting in laravel

I just add my laravel project in my cpanel but when I try to add it's showing an error.

SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into doctors (image, name, title, ps, updated_at, created_at) values (public/uplodeimage/66077480_Untitled-1.png, Dr. Mahidhar Valeti, MBBS, MS (Gen Surgery), FRCS (Eng), FRCS (Ireland), FICS (USA), 0, 2019-12-26 16:53:08, 2019-12-26 16:53:08))

it's working fine in localhost but showing this error after adding it to live server.

0 likes
5 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

Have you tried changing mysql

'strict' => false,

in database.php. Also there are a lot of stackoverflow post on this.

6 likes
siangboon's avatar

did you setup your doctors table properly in cpanel? usually the id should be auto increment... the error seem that the id need to be filled with value by your own.

1 like
siangboon's avatar

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.)

by turning off the strict mode, any invalid or missing value will not be taking care anymore...

2 likes

Please or to participate in this conversation.