php - Duplicate key Entry when no values are duplicatesGet the solution ↓↓↓
I am getting a very weird duplicate entry error when no values are even identical...
INSERT INTO offer_status (id,user_id,sql_id,disabled) VALUES ('8854011812','8854','11812','0')
#1062- Duplicate entry '2147483647' for key 'PRIMARY'
This does not make sense to me at all!
Note: This code is not normally executed, I am just trying to debug. Normally in my PHP I have:
$offer=$campid; $id=$user_id.'0'.$offer; $sql="INSERT INTO offer_status (id,user_id,sql_id,disabled) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE disabled=VALUES(disabled)"; $db->prepare($sql)->execute(array($id, $user_id, $offer, 0));
id is the primary key. What is going on here?
Added: Result of
Field Type Null Key Default Extra id int(12) NO PRI NULL user_id int(12) NO NULL sql_id int(12) NO MUL NULL favor tinyint(4) NO 0 disabled tinyint(4) NO 0 pref int(2) NO 0
8854011812 is out of
int range. It will be replaced by the max
int number which is
The second time you insert a value greather than the
int max, you will get a duplicate key error.
If you need such high numbers you can change your data type to
Oh i see. Since you have mentioned that
ID is the primary, I guess the data type of which is
int and which the maximum value for
SIGNED INT is
2147483647. You should have change the data type to
VARCHAR(15) so the value will be cattered.
The value you are inserting
8854011812 is kinda out of range to which an
int can hold.
People are also looking for solutions of the problem: your system folder path does not appear to be set correctly. please open the following file and correct this: index.php
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.