1062 Duplicate Entry Error Fix
#1
Posted 15 July 2006 - 07:24 PM
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
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#2
Posted 16 July 2006 - 12:54 AM
#3
Posted 21 July 2006 - 03:52 PM
enigma1, on Jul 16 2006, 12:54 AM, said:
Had SIMILIAR PROBLEM!
Thanka!
#4
Posted 21 July 2006 - 03:58 PM
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#5
Posted 21 July 2006 - 05:23 PM
jpweber, on Jul 21 2006, 10:58 AM, said:
J
And one other thing. Even if you add an extra auto-increment column to get around it (and that will work) you basically try to hide a problem instead of troubleshooting it. The tep_session_start should generate a unique session via the core php functions. Theoretically and with the default oscommerce there is no issue. So something is going on with your store that causes it.
#6
Posted 21 July 2006 - 05:33 PM
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#8
Posted 02 August 2006 - 07:53 PM
jackrabbit, on Aug 2 2006, 03:47 PM, said:
;-j
You can truncate table sessions when there are no customers online, but really ... the more I've researched, the more I've come up with the fact that you should just go into your phpmyadmin, and change the value of your sesskey in the sessions table to INT, not VarChar. You can always change it back. Just try it; I bet your problems go away.
Go into phpmyadmin and edit the sesskey. Set it to int(32) and set it to auto-increment. Problems solved, and no more problems arise. Worked for me (and several others). Let me know,
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#9
Posted 02 August 2006 - 11:30 PM
jpweber, on Aug 2 2006, 03:53 PM, said:
Go into phpmyadmin and edit the sesskey. Set it to int(32) and set it to auto-increment. Problems solved, and no more problems arise. Worked for me (and several others). Let me know,
J
I appreciate your working on a solution to this, but I have to say that Enigma's comment seems quite relevant. Don't you think that, regardless of the results of the fix you propose, you are opening up a potential security risk with it? I have to admit that I don't know enough to be able to say one way or another.
My site is working right now, so I don't feel like I have to put it at risk. My problem is just that when I set products to special I recieve the error once then it goes away until I set another product to special. I would like to know more about troubleshooting this error, but I'm afraid I dont' know where to start.
#10
Posted 03 August 2006 - 01:34 AM
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#11
Posted 03 August 2006 - 12:37 PM
jpweber, on Aug 3 2006, 09:34 AM, said:
J
I totally agree with Mark on this.
First of all, I am not sure those sessions will still function but even if they do it is now so much easier to guess an active session id in use by somebody else.
If I go to your store with cookies disabled and get session id 2345 in my url's then chances are pretty high that if I alter that to 2344 I get the information from the previous customer.
With random session id's (alphanumeric or even plain numeric) that is not such a straightforward issue.
And Mark is correct, you are eliminating symptoms not the root cause. if you get duplicate entries then your table is either not cleared, you are generating session id's like wildfire and thus increasing the chances of session id collision or for some other reason you are trying to insert the same session id (instead of updating the existing one).
#12
Posted 03 August 2006 - 02:23 PM
But there's no doubt, even before I added a contribution, I was getting 1062 duplicate error messages. And that's on a clean installation of OSC. I had to constantly truncate the sessions table. So *something* had to be fixed. Through my research, that was my fix. With my customer base, it's highly unlikely that an end-user is going to know how to alter his session -- and even if he does know (which he won't, because I don't even know how to do it), I'm still doubtful he'll get the information from a previous session. As for now, my OSC, 6 contributions later, is functioning well.
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#13
Posted 03 August 2006 - 03:15 PM
jpweber, on Aug 3 2006, 10:23 PM, said:
But there's no doubt, even before I added a contribution, I was getting 1062 duplicate error messages. And that's on a clean installation of OSC. I had to constantly truncate the sessions table. So *something* had to be fixed. Through my research, that was my fix. With my customer base, it's highly unlikely that an end-user is going to know how to alter his session -- and even if he does know (which he won't, because I don't even know how to do it), I'm still doubtful he'll get the information from a previous session. As for now, my OSC, 6 contributions later, is functioning well.
J
well, sure, it can very well be that it is an error that comes with the default install.
But if you do it with INT and Autoincrement, at least make sure that the session id is NEVER shown in the url's by forcing cookies. That way they are ALWAYS stored in cookies and not readily visible.
Then again forcing cookies has its own pro's and con's.
Still, that is only a small improvement as people who want to look for other peoples data are bound to know how to read that cookie and still know what likely active id's are.
It is basically like giving all the people in your street a combination lock to their cars and make the combinations sequential. So you know, only if he wants to ofcourse, that your neighbour can have a joy-ride in yours any time.
#14
Posted 03 August 2006 - 06:23 PM
#15
Posted 03 August 2006 - 06:49 PM
J
Simple 1-2-3 Intructions on how to get, install and configure SSL
The Google Sandbox explained
Simple to follow instructions on how to change the look of your OSC
How To Make A Horrible OSC Website
my toolbox: PHP Designer 2007 - Winmerge - phpMyAdmin - WS_FTP - Photoshop - Paint Shop Pro - Crimson Editor
my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
#16
Posted 03 August 2006 - 06:57 PM
$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) . "')");
}
Notice the code performs a check query with the session key passed and inserts this as a new key only when the key is not found in the database.
Now it could be something else like a null key. Have you implement the latest osc upgrade?
http://www.oscommerce.com/solutions/downloads
It has a specific check filtering the session id with the tep_session_start() function. Make sure you have those changes integrated with your store.
#17
Posted 18 August 2006 - 05:29 PM
enigma1, on Aug 3 2006, 11:57 AM, said:
$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) . "')");
}
Notice the code performs a check query with the session key passed and inserts this as a new key only when the key is not found in the database.
Now it could be something else like a null key. Have you implement the latest osc upgrade?
http://www.oscommerce.com/solutions/downloads
It has a specific check filtering the session id with the tep_session_start() function. Make sure you have those changes integrated with your store.
I'm sorry I am new to all of this and am getting this error. What is the solution? Thanks in advance...
#18
Posted 19 August 2006 - 09:50 AM
ehong33234, on Aug 18 2006, 05:29 PM, said:
I have just met that problem.and now i've removed it.
according to enigma1, osc has made sure that the key item can't be insert twice. but for mysql,there is such a condition that if the string is too long ,it will be cut short to the certain length.
for example: 123456789 exists in the database, if you insert 123456789123,it won't find 123456789123 in the table,but when you insert 123456789123 into the table ,mysql cut it to 123456789 automatically,so,there shows an error.
so,to solve the problem .
first when you have klicked on one category. make sure that in the address there is like:".../index.php?cPath=44&osCsid=0983152dd2ebf0ad25171fbfbdef3c31", and there is nothing after this string. if there is ,the error occurs. and then you should exam you file "./includes/boxes/categories",make sure that the href link is right.
this is my first threat here. sorry for my pool english.
#19
Posted 19 August 2006 - 12:47 PM
Whilst everything looked fine on the surface, dropping and reinstalling all 'orders' tables fixed the problem. Basically it was the database tables that were the problem.
Vger
#20
Posted 19 August 2006 - 02:32 PM
xiaoge, on Aug 19 2006, 04:50 AM, said:
according to enigma1, osc has made sure that the key item can't be insert twice. but for mysql,there is such a condition that if the string is too long ,it will be cut short to the certain length.
for example: 123456789 exists in the database, if you insert 123456789123,it won't find 123456789123 in the table,but when you insert 123456789123 into the table ,mysql cut it to 123456789 automatically,so,there shows an error.
so,to solve the problem .
first when you have klicked on one category. make sure that in the address there is like:".../index.php?cPath=44&osCsid=0983152dd2ebf0ad25171fbfbdef3c31", and there is nothing after this string. if there is ,the error occurs. and then you should exam you file "./includes/boxes/categories",make sure that the href link is right.
this is my first threat here. sorry for my pool english.
This is actually valid. It can happen with the default functions. I have an extra filter to check the key length specifically for this reason. However the default osc sessions.php doesn't. So you do need to check the length in tep_session_start() where it flags the sane id. So the key should be 24<= key <= 32 digits. Or in the _sess_write() handler
Edited by enigma1, 19 August 2006 - 02:33 PM.









