Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

1062 Duplicate Entry Error Fix


jpweber

Recommended Posts

What does that mean, in Layman's terms, enigma? I mean, I changed my sesskey back to varchar(32), no autoincrement, but I'm still getting at the bottom of the page - primarily when I go to login or create_account and then go to another page:

 

1062 - Duplicate entry 'd588ac8f1fffe6b3c490188a40eaafce' for key 1

 

insert into sessions values ('d588ac8f1fffe6b3c490188a40eaafce?osCAdminID=f3cdab335d59c0920155ebdb035fe1c4', '1156214611', 'cart|O:12:\"shoppingcart\":4:{s:8:\"contents\";a:0:{}s:5:\"total\";i:0;s:6:\"weight\";i:0;s:12:\"content_type\";b:0;}language|s:7:\"english\";languages_id|s:1:\"1\";currency|s:3:\"USD\";navigation|O:17:\"navigationhistory\":2:{s:4:\"path\";a:1:{i:0;a:4:{s:4:\"page\";s:18:\"create_account.php\";s:4:\"mode\";s:3:\"SSL\";s:3:\"get\";a:1:{s:6:\"osCsid\";s:76:\"d588ac8f1fffe6b3c490188a40eaafce?osCAdminID=f3cdab335d59c0920155ebdb035fe1c4\";}s:4:\"post\";a:0:{}}}s:8:\"snapshot\";a:0:{}}wishList|O:8:\"wishlist\":0:{}')

 

[TEP STOP]

 

Can you help me out in regards to what to do?

 

I just ran into this problem - Duplicate Entry in the sessions table - after downloading my client's /includes/languages/english.php and /includes/languages/english/*.php files. The cart owner edits these files in the osC backend admin tool as they're his information regarding everything - shipping, etc.

 

Start with the page where you are getting the error (mine was on catalog_index.php) and go BACK to the page where the link is to the problem page. My link was on index.php. Now, hover over the link and check the URL that it's going to send you to. Does it have multiple session IDs in the URL? Appended to each other behind the URL to the page?

 

I'll put some spaces in but an example:

www . site . com/ catalog_index.php ? osCsid=b4a0b7ae7bfed16e797ddf0a3c56a940 ? osCAdminID=bf6255d450ad1a1e409bfcd189b3aa9d

 

Notice the TWO session IDs appended to each other (one osCsid and one osCAdminID). And the area between quotes, in red, in your example. I've seen 4 or 5 appended to each other. The only place I have this problem is in the languages files that my cart owner has edited himself. He copies links from his browser, while he's logged into the cart on one browser and into the admin area on another browser. Then he pastes those copied links into a language page (Yup, osCAdminID=xxxxxx.... and all) and saves it. Now it's a permanent part of the file and will always display, AND will always add the current users osCsid in there too so of course it's too long! or a duplicate or whatever.

 

Take your production languages files and go through them. A good text editor will find the pasted in ids in no time. This doesn't help with the other problems in this thread but I think it may be the answer to your example above.

Link to comment
Share on other sites

  • 2 months later...
  • Replies 50
  • Created
  • Last Reply

I am using the contrib "FAST EASY CHECKOUT 3.2" and "HOW DID YOU HEAR ABOUT US? 1.5"

 

When I hit "continue" on my create_account3.php page, I get this error:

 

1062 - Duplicate entry '11' for key 1

insert into customers_info (customers_info_id, customers_info_date_of_last_logon, customers_info_number_of_logons, customers_info_date_account_created, customers_info_date_account_last_modified) values ('11', now(), '1', now(), now() )

[TEP STOP]

 

but it does successfully writes the customer's info to the db

 

any ideas why this is happening or how to fix it?

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hi guys,

 

 

I have a similar problem and it must definitely be casued by a contribution so maybe if we all knew what mods were installed on everybody's osc's that are having these problems?

 

Here's mine:

 

I have SPPC installed (as well as PDFexport, CVV mod, MaxiDVD multiple images, Who's Online Enhancement, AutoThumbnail, Easy Populate, SEO Assistant, SEO URLs, to name a few) , and they are working properly except for one thing, when i try to copy a product, it gives me a 1062 - Duplicate entry '0-638' for key 1. This has only started happening after SPPC was installed...

 

When you hit the back button, the new product has been copied correctly and appears in the list.

 

Now, when you browse the product listing on the main site, the price is displayed correctly, but when you click into a product info page, the price appears as 0.00. However, when you add the product to your cart anyway, the price in the shopping cart appears correctly.

 

So, its just the product info page which seems to get affected by this problem. Would anyone have any idea why this is happening? Should i change something to INT instead of autoincrement in the DB or is there another way?

 

Thanks.

Link to comment
Share on other sites

  • 3 weeks later...

Just for the record, it seems using Paypal_IPN_v2.2 and Unique Order Number contribs will also get you 1062 Duplicate entry error. Customers might choose to use Paypal and leave without completing the order leaving an Order_ID of "0" in Order DB. The next customer that comes along and choses Paypal as their payment method won't be able to complete the order and will get to see the previous customer's name, contacts and shipping information.

 

Can't find any remedies for this issue yet.

Link to comment
Share on other sites

  • 2 months later...

After trying to resolve a Duplicate Entry 1062 Error for several hours, I finally figured out the problem. My client had purchased an SSL certificate and accidently typed in the wrong domain name to purchase it under. There was only one letter difference, but the wrong ssl domain was being recorded in the sessions table and not allowing the creation of accounts. I have disabled ssl forr now until the correct certificate is purchased. I don't think this is the problem for most, but maybe it will help someone.

Link to comment
Share on other sites

  • 1 month later...

I also get a duplicate entry error - when copying products.

 

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

insert into products_description (products_id, language_id, products_name, products_description, short_desc, products_url, products_viewed) values ('46', '1', 'Electronic Automatic Leveling Rotating Laser', '
The LS521 Laser is a new generation of fully automatic self leveling rotating laser 
blah blah ... Used by earthmovers, agriculture, general builders, concretors and all trades where accuracy with rugged reliability over a large working range is what you need.

\r\n

', '
short description2 - includes formatting g dggd gdg dg  dg dg g dg deg d g
\r\n

', '', '0')

[TEP STOP]

 

I have a lot of contribs & hacks ...

I know only a little of sessions & databases, rely on guesswork mostly. So Im guessing it has something to do with the product descriptions. Mostly because Ive done a bit of messing around with short descriptions & the like. .. Although Key 1 probably means "products_id" in which case, yeah It needs to have a different ID... i guess.

 

Contributions:

FCK

rmh referral (How Did You Hear About Us)

Ultimate SEO URLs v2.1

STS v4.4

"On the Fly" Auto Thumbnailer using GD Library

Anti Robot Validation v2.5

Define Content

info pages

short description

Related Products

featured Products

Active Countries v2.11

Aust Post

.. theres a stack more

 

Not really a big problem at this stage.. but I want to track this discussion for later when I have more time.

Thanks all, for the really useful info thus far.

Link to comment
Share on other sites

  • 2 weeks later...

After installing, I received the following error message on every page in the admin section. My error was ...

 

1062 - Duplicate entry 'c07c86415d6c4ccdc061a352de1fe702' for key 1

 

insert into sessions values ('c07c86415d6c4ccdc061a352de1fe7022032cd70', '1186804470', 'language|s:7:\"english\";languages_id|s:1:\"1\";selected_box|s:13:\"configuration\";')

 

 

I noticed the "duplicate entry" was a truncated version (32 char) of the value in the "insert into sessions values" SQL (40 char). It seems the "sesskey" column in "sessions" should be varchar(40) and not varchar(32). Running the following SQL against my database fixed this problem for me. Make sure you are in the correct database (MySQL catalog) for your osCommerce setup before running.

 

ALTER TABLE `sessions` MODIFY COLUMN `sesskey` VARCHAR(40) NOT NULL;

 

 

In general, the session key should be a unique, but random, identifier, and the total space of random identifiers should be sparsely populated with actively used identifiers at any given time. Auto-incremented integers are a bad idea because they are unique, but not random, and all the active ones are next to each other. It is easy to guess neighboring active session identifiers and impersonate another user.

Link to comment
Share on other sites

  • 3 weeks later...

Hello, I was also receiving a similar error, which after some thorough research I had found that when the function _sess_write was looking up the $key value (which should only be 32 char long) the $key value actually had the 32 char long key plus ?active= blah blah so, somewhere something was setting the key to be a key + some http variables, at any rate, i just added 2 lines to my _sess_write function:

 

	function _sess_write($key, $val) {
  global $SESS_LIFE;

  $expiry = time() + $SESS_LIFE;
  $value = $val;

  //trim off extra crap on key
  $key = substr($key, 0, 32);

  $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
  $check = tep_db_fetch_array($check_query);

  if ($check['total'] > 0) {
	return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
  } else {
	return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
  }
}

 

For those of you who dont know where to find that particular function, it is in the includes/functions/sessions.php file.

 

Hope this helps...

 

Jon

Link to comment
Share on other sites

  • 2 months later...
I am using the contrib "FAST EASY CHECKOUT 3.2" and "HOW DID YOU HEAR ABOUT US? 1.5"

 

When I hit "continue" on my create_account3.php page, I get this error:

 

1062 - Duplicate entry '11' for key 1

insert into customers_info (customers_info_id, customers_info_date_of_last_logon, customers_info_number_of_logons, customers_info_date_account_created, customers_info_date_account_last_modified) values ('11', now(), '1', now(), now() )

[TEP STOP]

 

but it does successfully writes the customer's info to the db

 

any ideas why this is happening or how to fix it?

 

 

I met this problem when I used SSL.

My solution is changing the PHP code from

tep_redirect(URL);

to

echo '<html><head><meta http-equiv="refresh" content="0;URL=' . URL . '"></head></html>';

exit();

in login.php, create_account.php, and checkout_process.php.

 

Try it. It may work.

Link to comment
Share on other sites

  • 3 weeks later...
After installing, I received the following error message on every page in the admin section. My error was ...

 

1062 - Duplicate entry 'c07c86415d6c4ccdc061a352de1fe702' for key 1

 

insert into sessions values ('c07c86415d6c4ccdc061a352de1fe7022032cd70', '1186804470', 'language|s:7:\"english\";languages_id|s:1:\"1\";selected_box|s:13:\"configuration\";')

I noticed the "duplicate entry" was a truncated version (32 char) of the value in the "insert into sessions values" SQL (40 char). It seems the "sesskey" column in "sessions" should be varchar(40) and not varchar(32). Running the following SQL against my database fixed this problem for me. Make sure you are in the correct database (MySQL catalog) for your osCommerce setup before running.

 

ALTER TABLE `sessions` MODIFY COLUMN `sesskey` VARCHAR(40) NOT NULL;

In general, the session key should be a unique, but random, identifier, and the total space of random identifiers should be sparsely populated with actively used identifiers at any given time. Auto-incremented integers are a bad idea because they are unique, but not random, and all the active ones are next to each other. It is easy to guess neighboring active session identifiers and impersonate another user.

 

 

Folks! This is the solution you are looking for. If you change sesskey to INT you will always get a "duplicate entry for key 1" statement.

Just keep sesskey as a VARCHAR and then increase the size above 32 (I made mine 64) and make sure you turn off auto-increment as well.

 

Simple!

Link to comment
Share on other sites

  • 3 months later...
//trim off extra crap on key

$key = substr($key, 0, 32);

Thank you.

 

Your fix solved my duplicate entry error.

 

Now to solve the cookie vs. session problem that causes this situtation.

Link to comment
Share on other sites

  • 2 months later...
Hi all. I've researched this to the hilt, and I want to post a fix to the error I've been getting all along, which I've finally put an end to. It's the ol' 1062 Duplicate Entry error, and I have a fix for all. Everybody seems to get these, eventually, but very few people post about 'em in here.

 

The Problem -- Duplicate Entry 1062 Errors:

I kept having a duplicate error report for sessions. It is a problem with sessions. I was having this error everytime I selected create_account, or wishlist_help.

 

The Fix:

1) Go to your phpmyadmin, and select the sessions table

 

2) Select sesskey

 

3) Click edit

 

4) It's probably set at the OSC default, which is varchar(32). This is a mistake! Change the type to INT, the length/values should stay at 32.

 

5) Scroll all the way across to where you see extras and select AUTOINCREMENT from the drop down box.

 

6) Hit save button

 

All 1062 Duplicate Enty errors will not be resolved. You won't get 'em again!

 

 

If I am correct, OsCommerce creates sessions id for every visit to your website, in case a visitor has cookies disabled. Somehow during configuration, the sessions table probably wasn't configured to autoincrement. This was a simple fix that you wouldn't even need to change any of the values for your test runs. Just fix the sesskey and you're good to go!

 

J

 

THANKS!!! you're my hero :D

Link to comment
Share on other sites

  • 5 months later...

I have just moved my site to a new server. All the settings are the same. When I try to place an order, it will go all the way through to the order confirmation and then I get this:

 

1062 - Duplicate entry '0' for key 1

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, date_purchased, orders_status, currency, currency_value) values

 

I took out all the personal info.

 

I have tried every trick I could find in these forums with no change. Please Help

 

Thanks, Rickey

Link to comment
Share on other sites

  • 2 months later...

Hi all. I experienced the same problem yesterday. The log is below:

 

1062 - Duplicate entry 'li20tl2he6pen6fd35vtpm5q75' for key 1

 

insert into sessions values ('li20tl2he6pen6fd35vtpm5q75', '1234550946', 'language|s:7:\"english\";languages_id|s:1:\"1\";selected_box|s:13:\"configuration\";')

 

Using my phpmyadmin 2.11.9 I looked for the "sessions" configuration and noticed that the index value for the utilized space was corrupted and red colored.

I used the phpmyadmin optimizer. The index was dimensioned to 4,096 B, black colored, and the problem was solved.

 

Hope this can help you.

Link to comment
Share on other sites

  • 1 month later...

Hello all,

 

i have the same problem...for some reasons, i cannot edit a product..i can add it to multiple categories (usine Multiplecategories mod) but when i try to edit the product i get the following error :

 

1062 - Duplicate entry '38-26' for key 1

insert into products_to_categories (products_id, categories_id) values ('38', '26')

[TEP STOP]

 

and obviously it does not record my changes...i went trough the forums and tryed various solutions including those on this topic ..but did not work out..

 

any ideas ?

 

Kyli

Link to comment
Share on other sites

  • 2 weeks later...
Hi all. I experienced the same problem yesterday. The log is below:

 

1062 - Duplicate entry 'li20tl2he6pen6fd35vtpm5q75' for key 1

 

insert into sessions values ('li20tl2he6pen6fd35vtpm5q75', '1234550946', 'language|s:7:\"english\";languages_id|s:1:\"1\";selected_box|s:13:\"configuration\";')

 

Using my phpmyadmin 2.11.9 I looked for the "sessions" configuration and noticed that the index value for the utilized space was corrupted and red colored.

I used the phpmyadmin optimizer. The index was dimensioned to 4,096 B, black colored, and the problem was solved.

 

Hope this can help you.

 

This worked for me.

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

 

I had the following on a client's site that was running a clean OsC2.2 which I then added the SPPC mod to:

 

1062 - Duplicate entry '0-133' for key 1

 

insert into products_groups (customers_group_id, customers_group_price, products_id) values ('', '', '133')

 

[TEP STOP]

 

This error occured when the client tried to use the duplicate product function. After reading this thread about 10 times over along with a lot of other forums posts elsewhere on 1062s, I saw the pattern between everyone's error and worked out why my client was getting his.

 

As I understand a 1062 happens because somewhere in your database a field is not auto-incrementing when it should be. The error tells you which database table to look in (in the case I quote above it was products_groups). Try setting the first field (in this case customers_group_id) to auto-increment. This will then prevent the duplicate entries. I hope that helps those of you that are having trouble.

 

Happy OsC'ing,

 

Dani

There are 3 types of people - those who can count, and those who can't.

Link to comment
Share on other sites

  • 3 months later...

I get the same error with products_to_categories.... I tried your "auto-increment" change, and that "moved" the error to the customer_group DB!

 

The error happens when I try to add a new, or update an existing product!

 

Any other solutions?

 

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

 

insert into products_to_categories (products_id, categories_id) values ('0', '0')

 

[TEP STOP]

 

I've narrowed it to "admin/categories.php... Started after installing the SPPC mod!

 

Hi all,

 

I had the following on a client's site that was running a clean OsC2.2 which I then added the SPPC mod to:

 

 

 

This error occured when the client tried to use the duplicate product function. After reading this thread about 10 times over along with a lot of other forums posts elsewhere on 1062s, I saw the pattern between everyone's error and worked out why my client was getting his.

 

As I understand a 1062 happens because somewhere in your database a field is not auto-incrementing when it should be. The error tells you which database table to look in (in the case I quote above it was products_groups). Try setting the first field (in this case customers_group_id) to auto-increment. This will then prevent the duplicate entries. I hope that helps those of you that are having trouble.

 

Happy OsC'ing,

 

Dani

Link to comment
Share on other sites

  • 1 year later...

I tried the fix and when I click on save I get this error, I tried many times over and it doesnt work.

 

Error

SQL query:

 

ALTER TABLE `sessions` CHANGE `sesskey` `sesskey` INT( 32 ) NOT NULL

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 1

 

Does anyone know why I get this?

Link to comment
Share on other sites

  • 5 months later...

Thx 4 this fix, works fine.

 

If you have problems and cant use your mysqladmin/phpmysqladmin or other mysql server software corectly,

 

dump the sessions table with this code:

 

DROP TABLE IF EXISTS sessions;

 

CREATE TABLE sessions (
 sesskey int(32) NOT NULL auto_increment,
 expiry int(11) unsigned NOT NULL,
 value text NOT NULL,
 PRIMARY KEY (sesskey)
);

 

If you are done, delete the osc Cokkies in your browser, reload the side and WOW ... ^^

 

Best regards Peter

 

"Edit: one ask i have about this error: on the 2.2RC2a i dont get this error with this sessions table:

 

CREATE TABLE `sessions` (
 `sesskey` varchar(32) NOT NULL default '',
 `expiry` int(11) unsigned NOT NULL default '0',
 `value` text NOT NULL,
 PRIMARY KEY  (`sesskey`)
) ENGINE=MyISAM;

 

So i wonder me now :huh:

 

Edit end

Link to comment
Share on other sites

Upppsss:

 

Now after this fix, i cant go on the Admin Page: Cookie problems ?!?

 

"Fehler: Umleitungsfehler

 

Die aufgerufene Website leitet die Anfrage so um, dass sie nie beendet werden kann.

 

* Dieses Problem kann manchmal auftreten, wenn Cookies deaktiviert oder abgelehnt werden."

Link to comment
Share on other sites

Upppsss:

 

Now after this fix, i cant go on the Admin Page: Cookie problems ?!?

 

"Fehler: Umleitungsfehler

 

Die aufgerufene Website leitet die Anfrage so um, dass sie nie beendet werden kann.

 

* Dieses Problem kann manchmal auftreten, wenn Cookies deaktiviert oder abgelehnt werden."

 

Im again, ok i have update my php5 Version to 5.3.7RC4-dev (Zend: 2.3.0), downloaded the osc 2.3.1 again today, delete all files on space, DB Tables and cookies in Browser, install again and its works (DB fix inclusive).

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...