Forums / General Questions / Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Locked

Views: 7,526

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
9 Jan 2008, 11:00 AM
#1
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Yes, Another "1062 Duplicate entry '0' for key 1" thread!

1062 Duplicate entry '0' for key 1
in:
[update fast_whos_online set customer_id = '0', full_name = '¥Guest', ip_address = '78.151.199.57', time_last_click = '1199876169', last_page_url = '/cart/index.php?main_page=page&id=16&chapter=0&zenid=5fca194f09b3d02d1cb79a978103c731', host_address = 'OFFICE_IP_TO_HOST_ADDRESS', user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' where session_id = '5fca194f09b3d02d1cb79a978103c731' and ip_address='78.151.199.57']

^^^ Is the error I'm getting a LOT of the time.

I'm running:

Zen Cart 1.3.7.1
PHP 4.4.7
MySQL 4.0.27

The problem seems to occur (during testing) because I am accessing a lot of the page from the same I.P address. I think it may be due to me browsing as a ''guest' and the 'whos_online' table not correctly handling the fact that I'm accessing many pages as different 'guests' in a short period of time.

I've tried a few of the SQL patches to reinstate the auto_increment function but they are of no avail.

Any help would be appreciated as my cart is ready to go public soon.

www fastcardirect co uk/cart

9 Jan 2008, 4:25 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

What happens if you "empty" the table using the "Empty" button in phpMyAdmin? Or TRUNCATE it using an SQL statement?

Perhaps it's got some confusing data in it and needs to start clean.

.
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.

10 Jan 2008, 5:07 PM
#3
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Have gone back and emptied the table, still occasionally giving me the error. When I'm logged into my test account rather than as a guest, it seems to work ok.

10 Jan 2008, 7:48 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Fastcar:

I'm running:

Zen Cart 1.3.7.1
PHP 4.4.7
MySQL 4.0.27

... my cart is ready to go public soon.Have you considered upgrading to 1.3.8a before you go live?

.
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.

10 Jan 2008, 7:49 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Fastcar:

1062 Duplicate entry '0' for key 1
in:
[update fast_whos_online set customer_id = '0', full_name = '¥Guest', ip_address = '78.151.199.57', time_last_click = '1199876169', last_page_url = '/cart/index.php?main_page=page&id=16&chapter=0&zenid=5fca194f09b3d02d1cb79a978103c731', host_address = 'OFFICE_IP_TO_HOST_ADDRESS', user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' where session_id = '5fca194f09b3d02d1cb79a978103c731' and ip_address='78.151.199.57']

> 
> ^^^ Is the error I'm getting a LOT of the time.What is the structure of your whos_online table?
You can get this quickly via phpMyAdmin by clicking on Export, selecting just this table, choosing structure-only, and clicking Go

.
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.

11 Jan 2008, 9:15 AM
#6
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

-- 
-- Table structure for table `fast_whos_online`
-- 

CREATE TABLE `fast_whos_online` (
  `customer_id` int(225) NOT NULL auto_increment,
  `full_name` varchar(64) NOT NULL default '',
  `session_id` varchar(128) NOT NULL default '',
  `ip_address` varchar(15) NOT NULL default '',
  `time_entry` varchar(14) NOT NULL default '',
  `time_last_click` varchar(14) NOT NULL default '',
  `last_page_url` varchar(255) NOT NULL default '',
  `host_address` text NOT NULL,
  `user_agent` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`customer_id`),
  KEY `idx_ip_address_zen` (`ip_address`),
  KEY `idx_session_id_zen` (`session_id`),
  KEY `idx_customer_id_zen` (`customer_id`),
  KEY `idx_time_entry_zen` (`time_entry`),
  KEY `idx_time_last_click_zen` (`time_last_click`),
  KEY `idx_last_page_url_zen` (`last_page_url`)
) TYPE=MyISAM AUTO_INCREMENT=48 ;

-- 
-- Dumping data for table `fast_whos_online`
-- 

INSERT INTO `fast_whos_online` VALUES (0, '¥Spider', '', '66.249.72.164', '1200040570', '1200042434', '/cart/index.php?main_page=product_info&cPath=92&products_id=337', 'OFFICE_IP_TO_HOST_ADDRESS', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
INSERT INTO `fast_whos_online` VALUES (46, '¥Guest', 'a1a2bac7c46a3b0a12fed65154f6f2ca', '78.151.219.83', '1200042633', '1200042633', '/', 'OFFICE_IP_TO_HOST_ADDRESS', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');
INSERT INTO `fast_whos_online` VALUES (47, '¥Guest', '09a2c4c423503f00133368758b2e72ad', '84.45.139.35', '1200042857', '1200042857', '/', 'OFFICE_IP_TO_HOST_ADDRESS', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)');

Also, I get this error message when there is a googlebot crawling the cart. It's as though there is only a few connections allowed at a time and thus, after 2-4 everything gets locked up.

11 Jan 2008, 6:36 PM
#7
drbyte avatar

drbyte

Sensei

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

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Fastcar:

customer_id int(225) NOT NULL auto_increment,

Your customer_id field should not be auto_increment ... that's what's causing your headaches.
With phpMyAdmin you should be able to Edit your table settings and uncheck the auto-increment option (or deselect it from pulldown, etc).

.
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.

11 Jan 2008, 10:06 PM
#8
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Have just gone and changed that, will see in the next couple of days if it solves the issue. I trust your advice and thank you in advance.

13 Jan 2008, 12:41 AM
#9
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

DrByte unfortunately that did not seem to fix the problem, are there other suggestions I should try?

13 Jan 2008, 7:08 AM
#10
drbyte avatar

drbyte

Sensei

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

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Fastcar:

,
PRIMARY KEY (customer_id),

This table should not have a primary key.
And, since you've got one set, it's forcing uniqueness on every "0" record, which would happen for every "guest"/visitor.

Drop your primary key from that table.
You could use the following via the SQL Patch tool:

ALTER TABLE whos_online DROP PRIMARY KEY;

or add your fast_ prefix and do it in phpMyAdmin.

.
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.

14 Jan 2008, 2:10 PM
#11
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: Yes, Another "1062 Duplicate entry '0' for key 1" thread!

Thanks Dr, that seems to be doing the trick at the minute. Really appreciate your help. I'll let you know if anything like this pops up again.