Forums / Upgrading from 1.3.x to 1.3.9 / 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Locked

Views: 13,491

Results 1 to 20 of 25
This thread is locked. New replies are disabled.
6 Jan 2008, 5:06 PM
#1
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

When I tried to update my database I received the error:

1062 Duplicate entry '0' for key 1
in:
[INSERT INTO project_version_history (project_version_key, project_version_major, project_version_minor, project_version_patch, project_version_date_applied, project_version_comment) SELECT project_version_key, project_version_major, project_version_minor, project_version_patch1 as project_version_patch, project_version_date_applied, project_version_comment FROM project_version;]

Any ideas?

6 Jan 2008, 7:38 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

What version of PHP?
What version of MySQL?

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

6 Jan 2008, 8:28 PM
#3
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

PHP version: 4.4.4
MySQL version: 4.1.22-standard

6 Jan 2008, 9:14 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

If you use phpMyAdmin to look at that table, what indexes are associated with it?

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

7 Jan 2008, 4:21 AM
#5
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

I went to phpMyAdmin and noticed this:

Create new database: No Privileges
```Perhaps this has something to do with it? Then looked up indexes for project_version_history and found:
     Indexes:         

Keyname Type Cardinality Action Field
PRIMARY PRIMARY 15 Edit / Drop project_version_id

7 Jan 2008, 6:07 AM
#6
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

It appears you've lost your auto_increment setting for the project_version_id field.

To reinstate it, you can add it via phpMyAdmin's table editor, or you can run this SQL statement:

ALTER TABLE project_version_history CHANGE COLUMN project_version_id  project_version_id tinyint(3) NOT NULL auto_increment;

The more important question is ... why did it lose that setting?
First, confirm that setting the auto_increment again solves it.

Then consider resetting all your auto_increment settings using the /zc_install/sql/db_rebuilt_autoincrement.sql script, running it via phpMyAdmin's Import tab.

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

7 Jan 2008, 6:41 AM
#7
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

I ran the SQL statement and received the message:

Your SQL query has been executed successfully (Query took 0.1879 sec)
     SQL query:        ALTER  TABLE project_version_history CHANGE  COLUMN project_version_id project_version_id tinyint( 3  )  NOT  NULL  AUTO_INCREMENT     
```I then retried to update the database from 1.3.6-->1.3.8a. I received this message:

in:
[select admin_id, admin_name, admin_pass from admin where admin_name = 'webmaster']

7 Jan 2008, 7:16 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Ellume:

in:
[select admin_id, admin_name, admin_pass from admin where admin_name = 'webmaster']

I gather there was nothing more to the error message than that? Normally something else appears before the "in:" part.

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

7 Jan 2008, 7:29 AM
#9
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Just an empty line where there normally is something.

One thing that might play a part is because of server space issues I wasn't able to create a separate folder like recommended (like the "/store_new") and do the swapping name. I simply overwrote the new version over the old. I do have backups of everything however so I can revert back if needed. It does seem this might leave unneeded files floating around, as such I'm considering to delete it and reupload the newversion again to keep things cleaner.

7 Jan 2008, 8:53 AM
#10
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Clean is always good.
However, I'd be surprised if that scenario were caused by any normal old files.

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

7 Jan 2008, 8:55 AM
#11
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Try following step 2(b) from this FAQ, but put the file in the **/zc_install/**includes/local folder instead:
https://www.zen-cart.com/tutorials/index.php?article=82

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

8 Jan 2008, 12:27 AM
#12
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

I cleaned up the files a bit. Retried and received the same error. I then created a file called configure.php with the following code

<?php
  define('STRICT_ERROR_REPORTING', true);
?>
```I placed this file in the zc_install/includes/local/ folder. I had to create the local folder because one did not exist. I ran the zc_install/index.php and went through the upgrade steps again, after entering in the admin info and clicked 'Update Database Now'. I received the same error:

in:
[select admin_id, admin_name, admin_pass from admin where admin_name = 'webmaster']

8 Jan 2008, 7:26 AM
#13
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

I gather you've got two checkboxes checked, right?

  • 1.3.6-to-1.3.7
  • 1.3.7-to-1.3.8

What happens if you do them one-at-a-time?

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

8 Jan 2008, 9:25 AM
#14
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Ah, now we are getting somewhere :laugh: I tried to upgrade from 1.3.6-->1.3.7 and it completed the upgrade with the following messages:

16 statements processed.
Note: 9 statements ignored. See "upgrade_exceptions" table for additional details.

[B]ATTENTION: Problems Found[/B][LIST]
[*]NOTE: Skipped upgrade statements: 9
See details at bottom of page for your inspection.
(Details also logged in the "upgrade_exceptions" table.)
Note: In most cases, these failed statements can be ignored,
as they are indications that certain settings may have already been set on your site.
If all the suggested upgrade steps have been completed (no recommendations left),
you may proceed to Skip Upgrades and continue configuring your site.[URL="http://javascript%3Cb%3E%3C/b%3E:popupWindow%28%27popup_help_screen.php?error_code=85%27%29"] more info...[/URL][/LIST]

SKIPPED: Cannot insert configuration_key "USE_SPLIT_LOGIN_MODE" because it already exists
SKIPPED: Cannot ADD column customers_paypal_payerid because it already exists.
SKIPPED: Cannot ADD column customers_paypal_ec because it already exists.
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot insert configuration_key "CC_ENABLED_SOLO" because it already exists
SKIPPED: Cannot insert configuration_key "CC_ENABLED_SWITCH" because it already exists
SKIPPED: Cannot insert configuration_key "CC_ENABLED_MAESTRO" because it already exists
SKIPPED: Cannot insert configuration_key "DEFINE_PAGE_NOT_FOUND_STATUS" because it already exists
SKIPPED: Cannot insert configuration_key "DEFINE_PAGE_NOT_FOUND_STATUS" because it already exists
SKIPPED: Cannot insert configuration_key "DEFINE_PAGE_NOT_FOUND_STATUS" because it already exists
SKIPPED: Cannot insert configuration_key "DEFINE_PAGE_NOT_FOUND_STATUS" because it already exists
```Would you advise continuing the upgrade from 1.3.7--->1.3.8a? Or perhaps check out some of these?
8 Jan 2008, 9:30 AM
#15
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Continue with the next step.

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

8 Jan 2008, 9:34 AM
#16
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Tried to upgrade 1.3.7--->1.3.8a and received the following error:

1062 Duplicate entry '0' for key 1
in:
[INSERT INTO query_builder (query_category, query_name, query_description , query_string) VALUES ('email,newsletters', 'Customers who have never completed a purchase', 'For sending newsletter to all customers who registered but have never completed a purchase', 'SELECT DISTINCT c.customers_email_address as customers_email_address, c.customers_lastname as customers_lastname, c.customers_firstname as customers_firstname FROM TABLE_CUSTOMERS c LEFT JOIN TABLE_ORDERS o ON c.customers_id=o.customers_id WHERE o.date_purchased IS NULL');]
8 Jan 2008, 11:01 AM
#17
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

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

8 Jan 2008, 11:12 AM
#18
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

I tried that and after doing another upgrade 1.3.7--->1.3.8a it returned back to the Database Upgrade page with the following messages:

71 statements processed.
Note: 27 statements ignored. See "upgrade_exceptions" table for additional details.

[B]ATTENTION: Problems Found[/B][LIST]
[*]NOTE: Skipped upgrade statements: 27
See details at bottom of page for your inspection.
(Details also logged in the "upgrade_exceptions" table.)
Note: In most cases, these failed statements can be ignored,
as they are indications that certain settings may have already been set on your site.
If all the suggested upgrade steps have been completed (no recommendations left),
you may proceed to Skip Upgrades and continue configuring your site.[URL="http://javascript%3Cb%3E%3C/b%3E:popupWindow%28%27popup_help_screen.php?error_code=85%27%29"] more info...[/URL][/LIST]

SKIPPED: Cannot insert configuration_key "SHOW_SHOPPING_CART_COMBINED" because it already exists
SKIPPED: Cannot insert configuration_key "ORDER_COMMENTS_INVOICE" because it already exists
SKIPPED: Cannot insert configuration_key "ORDER_COMMENTS_PACKING_SLIP" because it already exists
SKIPPED: Cannot insert configuration_key "ORDER_COMMENTS_PACKING_SLIP" because it already exists
SKIPPED: Cannot ADD column module_name because it already exists.
SKIPPED: Cannot ADD column module_mode because it already exists.
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot create table nochex_apc_transactions because it already exists
SKIPPED: Cannot create table nochex_sessions because it already exists
SKIPPED: Cannot create table nochex_sessions because it already exists
SKIPPED: Cannot create table nochex_sessions because it already exists
SKIPPED: Cannot create table nochex_sessions because it already exists
SKIPPED: Cannot ALTER or INSERT/REPLACE into table paypal_testing because it does not exist. CHECK PREFIXES!
SKIPPED: Cannot ALTER or INSERT/REPLACE into table linkpoint_api because it does not exist. CHECK PREFIXES!
```
I checked the database version in the admin section and it is now at 1.3.8 :laugh: I really appreciate all the help DrByte! Would you advise checking into any of the files that were skipped?
8 Jan 2008, 11:18 AM
#19
drbyte avatar

drbyte

Sensei

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

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Those skipped items all appear to be related simply to running the upgrade script multiple times.
Your database upgrade should be complete now.

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

8 Jan 2008, 11:24 AM
#20
ellume avatar

ellume

New Zenner

Join Date:
Jul 2007
Posts:
20
Plugin Contributions:
0

Re: 1062 Duplicate entry '0' for key 1 Error - 1.3.6-->1.3.8a

Again many thanks DrByte! :clap:All the best with everything!