Forums / General Questions / 1062 Duplicate entry '38' for key 1

1062 Duplicate entry '38' for key 1

Locked

Views: 1,766

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
16 Jan 2008, 12:31 AM
#1
henryvuong avatar

henryvuong

New Zenner

Join Date:
Aug 2006
Posts:
76
Plugin Contributions:
0

1062 Duplicate entry '38' for key 1

A new customer signed up with my cart today and he said that every time he tried to order, after filling up information he ended up with the message:

1062 Duplicate entry '38' for key 1
in:
[insert into customers_basket (customers_id, products_id,
customers_basket_quantity, customers_basket_date_added) values ('127',
'789', '1', '20080115')]

There's no other customer after him yet so I don't know what will happen to the next one. Can someone give me some information about this? Thanks.

16 Jan 2008, 5:40 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 1062 Duplicate entry '38' for key 1

You have probably done some sort of database backup/restore which has lost some settings or corrupted data.

The fastest (although not really the most recommended) way to fix it is to rebuild the table with the right structure.
The following will LOSE ALL YOUR CUSTOMER BASKET DATA, but should get rid of the error.
You can do this via the Admin->Tools->Install SQL Patch option, or via phpMyAdmin:

DROP TABLE IF EXISTS customers_basket;
CREATE TABLE customers_basket (
  customers_basket_id int(11) NOT NULL auto_increment,
  customers_id int(11) NOT NULL default '0',
  products_id tinytext NOT NULL,
  customers_basket_quantity float NOT NULL default '0',
  final_price decimal(15,4) NOT NULL default '0.0000',
  customers_basket_date_added varchar(8) default NULL,
  PRIMARY KEY  (customers_basket_id),
  KEY idx_customers_id_zen (customers_id)
) TYPE=MyISAM;

DROP TABLE IF EXISTS customers_basket_attributes;
CREATE TABLE customers_basket_attributes (
  customers_basket_attributes_id int(11) NOT NULL auto_increment,
  customers_id int(11) NOT NULL default '0',
  products_id tinytext NOT NULL,
  products_options_id varchar(64) NOT NULL default '0',
  products_options_value_id int(11) NOT NULL default '0',
  products_options_value_text BLOB NULL,
  products_options_sort_order text NOT NULL,
  PRIMARY KEY  (customers_basket_attributes_id),
  KEY idx_cust_id_prod_id_zen (customers_id,products_id(36))
) TYPE=MyISAM;

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.