inserting into table shows Duplicate entry #1062 while i am not entering primary key

1.2k Views Asked by At

I am trying to enter set of data in to my Cycles Table , The structure of the table as below.

Structure of the table

When I am trying to insert the data into the table. I get error as below.

 PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '65535' for key 'PRIMARY''

My question is I am not trying to insert values into my primary key field which is id. then why I am getting duplication error. check my insertion query below.

I believe when auto increment field is left empty that should add values by itself. enter image description here

When I made a manual check to see weather the record exit by

 Select * from Cycles where id = 65535

var_dump($resutls) shows empty array and count($resutls) is zero

enter image description here

1

There are 1 best solutions below

0
sanainfotech On

Thanks All

For your suggestion.

I found the error, I have to change in my table structure for id (smallint) to id (int(11)).

The smallint datatype was not doing any increments.

enter image description here