Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Custom Script broken - 1062 Duplicate entry '1' for key 'PRIMARY'


Jemrada

Recommended Posts

Hello,

 

We had an unfortunate problem after making some changes to a server with an old version of osCommerce installed. There is a custom script that was created many years ago. However, the script works fine up until it needs to communicate with the database. We are getting the following error when we click Add to Shopping Cart.

1062 - Duplicate entry '1' for key 'PRIMARY'

INSERT INTO products (products_id, products_quantity, products_model, products_image, products_price, products_date_added, products_last_modified, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) VALUES ('1', 100000, 'fonts: 
line 1: Abbey.ttf
font color: Silver
decal type: Window Lettering (Your Name)
decal option: 1 inch Tall x 5 inch Wide (As Shown)
', '', '5', '2015-03-28 6:51:46', '2015-03-28 6:51:46', '', '0.8', '0', '1', '0')

[TEP STOP]

You can see the page at http://www.decalcity.com/custom_decals3.php?decal_type=a_windshield_lettering.php

 

If you enter a sample in Step 2 and then scroll down to the bottom and click Generate. When the page loads click Add to Shopping Cart.

 

We have had multiple programmers look at this problem and have been unsuccessful in resolution.

 

I am looking for some ideas on what we can do or if someone is interested in trying to troubleshoot this for us.

Link to comment
Share on other sites

@@Jemrada

 

Quickly googling the error message gives you this...

 

The reason why the error has been generated is because there is already an existing value of 1 for the column ID in which you define it as PRIMARY KEY (values are unique) in the table you are inserting. Why not set the column ID as AUTO_INCREMENT?

 

Gota love Google...

 

Dan

Link to comment
Share on other sites

Thanks for that information. However, auto increment is set. We actually tried unsetting it and same thing happened. We also tried deleting ID 1, and get this error below.

1062 - Duplicate entry '1-1' for key 'PRIMARY'

INSERT INTO products_description (products_id, language_id, products_name, products_description, products_url, products_viewed) VALUES ('1', 1, 'Custom: Jeffrey




', 'fonts: 
line 1: Abbey.ttf
font color: Silver
decal type: Windshield Lettering
decal option: 3 inch x 33 inch
', '[ Custom made toobar
  
]


', 0);

[TEP STOP]

Link to comment
Share on other sites

@@Jemrada

 

Hummm....did you try running the insert query directly against the database ie via phpadmin or whatever you are using to see what happens?

 

Dan

Link to comment
Share on other sites

@@Jemrada

 

Jeffrey I just noticed that your second message is coming from a different table?  Was the insert successful on the first table and then run into a similar problem ie duplicate record when it attempted to write to the second table?

 

Dan

Link to comment
Share on other sites

Sorry, no this did not resolve it.

 

However, I can say it is resolved. I decided to role back the whole site to a previous full backup to a time before we did the php 5.5 update. Despite some minor errors. This major error is resolved.

 

Thanks for all your feedback.

Link to comment
Share on other sites

@@Jemrada

 

If you have this issue again (but hopefully you won't) you might want to have a look at this site and the comments posted towards the bottom of the page...lots of good suggestions and ideas on why it might happen.

 

http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-duplicate-entry-for-key-primary-o-1844.html

 

Dan 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...