Forums / Bug Reports / [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

[Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

Locked

Views: 6,278

Results 21 to 35 of 35
This thread is locked. New replies are disabled.
2 Mar 2016, 1:00 PM
#21
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

[Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

ok by running the query i get this response
NO_AUTO_VALUE_ON_ZERO,ERROR_FOR_DIVISION_BY_ZERO,N...
so seems to be the issue i might try and change the 0 to null and see what happens lol otherwise guess its up to the hosting company to resolve if they even come to the party on that who would know

2 Mar 2016, 1:10 PM
#22
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mydakota:

ok by running the query i get this response
NO_AUTO_VALUE_ON_ZERO,ERROR_FOR_DIVISION_BY_ZERO,N...
so seems to be the issue i might try and change the 0 to null and see what happens lol otherwise guess its up to the hosting company to resolve if they even come to the party on that who would know

Changing '0' for NULL may have unwanted implications in the rest of the code. They are not the same thing, and may give different return values in queries, and php code.
I think it is safer to talk to your hosting company

2 Mar 2016, 3:50 PM
#23
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

I would agree that the best solution (as one has already chimed in as having the same problem with the same host) if staying with this host would be to get the server settings fixed. The best solution for you as a store operator is to find someone that supports ZC/doesnt have this issue.

With regards to a solution associated with staying with this host in absence of them resolving the above issue, I've been looking for a post DrByte made about I think it was Windows servers... Regardless if it was windows or another server, there was something about switching assignments from 0 to null as 0 is a specific "integer" designation, while null is nothing and an auto-increment field should not allow NULL as a value and thus should auto-increment. That said, not including the auto-increment field in the assignment query also would force the auto-increment to occur.

So in this case: ```
$db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " ([B]products_attributes_id, [/B]products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, product_attribute_is_free, products_attributes_weight, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted, attributes_image, attributes_price_base_included, attributes_price_onetime, attributes_price_factor, attributes_price_factor_offset, attributes_price_factor_onetime, attributes_price_factor_onetime_offset, attributes_qty_prices, attributes_qty_prices_onetime, attributes_price_words, attributes_price_words_free, attributes_price_letters, attributes_price_letters_free, attributes_required)
values ([B]0,[/B]
'" . (int)$products_id . "',
'" . (int)$options_id . "',

If it were modified to:

$db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, product_attribute_is_free, products_attributes_weight, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted, attributes_image, attributes_price_base_included, attributes_price_onetime, attributes_price_factor, attributes_price_factor_offset, attributes_price_factor_onetime, attributes_price_factor_onetime_offset, attributes_qty_prices, attributes_qty_prices_onetime, attributes_price_words, attributes_price_words_free, attributes_price_letters, attributes_price_letters_free, attributes_required)
values (
'" . (int)$products_id . "',
'" . (int)$options_id . "',

Removing reference to: products_attributes_id
The problem would not exist in thisquery, but other related queries would also need to be modified.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Mar 2016, 3:52 PM
#24
drbyte avatar

drbyte

Sensei

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

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mydakota:

ok by running the query i get this response
NO_AUTO_VALUE_ON_ZERO,ERROR_FOR_DIVISION_BY_ZERO,N...
so seems to be the issue i might try and change the 0 to null and see what happens lol otherwise guess its up to the hosting company to resolve if they even come to the party on that who would know

Yours is the only site I've ever seen use that setting in 14 years. Zen Cart was not designed with that setting in mind. You'll need to remove that setting from your MySQL configuration, via your hosting company.

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

2 Mar 2016, 3:55 PM
#25
drbyte avatar

drbyte

Sensei

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

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mc12345678:

null is nothing and an auto-increment field should not allow NULL as a value and thus should auto-increment. That said, not including the auto-increment field in the assignment query also would force the auto-increment to occur.
Yes, and my nature, an auto-increment field is an integer value. It's extremely rare to ever use a 0 in an auto-increment field. It's certainly not something a shared-host should allow as a default.

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

3 Mar 2016, 8:32 AM
#26
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

Lol no luck with them this is one of there responses We apologize that you had to contact us and the team member that was assisting you earlier is asking for the version of your sql and is waiting for a response. Our Specialists stated that the issue was caused by the table itself.
When I called them all they could say as its not a issue with there server/database lol how can it not be when I can use the exact same backups and restore to a different server and it works . I even tryed making a new ZenCart install and just backing up the attribute tables and importing them to my issue site still same results . I now know why they call themselves CrazyDomains lol because of there crazy servers

3 Mar 2016, 9:56 AM
#27
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mydakota:

I now know why they call themselves CrazyDomains
When I first read your post I thought you where joking calling them that. But if it's a real name, it wouldn't be on my first choices.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

3 Mar 2016, 10:33 AM
#28
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

Doubt the will give my money back but if they don't do the right thing I at least make sure people know to avoid them

3 Mar 2016, 4:25 PM
#29
drbyte avatar

drbyte

Sensei

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

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

  1. Perhaps you can log a support ticket and ask them to turn off the NO_AUTO_VALUE_ON_ZERO setting, instead of tying it to a specific issue that they've been seeing as "someone else's problem".

  2. Or, if you can find out the complete result of this (instead of the chopped-off version which you posted), then we can tell your Zen Cart to use all the rest of the (applicable) settings:

mydakota:

ok by running the query i get this response
NO_AUTO_VALUE_ON_ZERO,ERROR_FOR_DIVISION_BY_ZERO,N...
so seems to be the issue i might try and change the 0 to null and see what happens lol otherwise guess its up to the hosting company to resolve if they even come to the party on that who would know

(Once you post the complete output of that sql_mode query, I'll show you how to tell ZC what to do with those.)

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

3 Mar 2016, 6:58 PM
#30
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

magically i get home and start playing and it is fixed hmmmm seems someone has fixed it very strange must have been the hosting company i will try find out what they did to fix it but i guess you guys probably know what they did anyhow but I would like to confirm it .

3 Mar 2016, 7:01 PM
#31
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

also ran the query again this is all i could get out of it

ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

4 Mar 2016, 3:20 AM
#32
drbyte avatar

drbyte

Sensei

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

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mydakota:

magically i get home and start playing and it is fixed hmmmm seems someone has fixed it very strange must have been the hosting company i will try find out what they did to fix it but i guess you guys probably know what they did anyhow but I would like to confirm it .

mydakota:

also ran the query again this is all i could get out of it

ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Ya, it looks like they turned off the NO_AUTO_VALUE_ON_ZERO setting.

FWIW Zen Cart v1.5.5 will include changes to minimize the risk of triggering problems if NO_AUTO_VALUE_ON_ZERO is enabled. (I can't guarantee plugins won't try to use 0-value inserts, but ZC core code should be less likely to trigger that starting with v155).

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

4 Mar 2016, 3:52 AM
#33
mydakota avatar

mydakota

New Zenner

Join Date:
Feb 2016
Posts:
58
Plugin Contributions:
0

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

Thank you guys for all your help really appreciate it

4 Mar 2016, 12:01 PM
#34
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mydakota:

magically i get home and start playing and it is fixed hmmmm seems someone has fixed it very strange must have been the hosting company i will try find out what they did to fix it but i guess you guys probably know what they did anyhow but I would like to confirm it .

Darn... I was really looking forward to seeing DrByte's proposed solution of how to tell the server to "ignore" this setting.. :) Ohh well, maybe the issue was addressed for webmanstudios as well??? If not, @webmanstudios, suggest having a similar discussion with the host to see if this can be resolved for you as well... No sense in working with ZC in a disabled state when so much more could be possible...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

24 Mar 2016, 7:06 PM
#35
drbyte avatar

drbyte

Sensei

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

Re: [Done v155] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

mc12345678:

Darn... I was really looking forward to seeing DrByte's proposed solution of how to tell the server to "ignore" this setting.. :)
See: https://github.com/zencart/zencart/commit/f456c766bb69575dce47b2776463400b2c42f4ac

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