Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35
  1. #1
    Join Date
    Feb 2016
    Posts
    58
    Plugin Contributions
    0

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

    not sure if to post this here please direct me to right place if not im new please help me , every time i try to add more the one attribute i get the time out please refresh page to try again in the error logs i get this UTC] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY' :: if i do a check msql table after trying to add attribute in zencart I see this in phpmyadmin database .products_attributes check warning Found row where the auto_increment column has the ......
    its weird because if i restore with the same backup files and sql to my test server wamp it works fine. but restoring to my web host crazydomains i get these auto_increment issues and cant add more than one attribute ive spent days trying to fix it and have become stuck. please please help me. ill attach log file below.

    [27-Feb-2016 06:49:37 UTC] PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY' :: insert into products_attributes (products_attributes_id, 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 (0,
    '311',
    '2',
    '5',
    '0',
    '+',
    '2',
    '1',
    '0',
    '+',
    '0',
    '0',
    '1',
    '',
    '1',
    '0',
    '0',
    '0',
    '0',
    '0',
    '',
    '',
    '0',
    '0',
    '0',
    '0',
    '0') in /home/anarchy2/public_html/includes/classes/db/mysql/query_factory.php on line 120

  2. #2
    Join Date
    Feb 2016
    Posts
    58
    Plugin Contributions
    0

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    plase help me ;(

  3. #3
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    Quote Originally Posted by mydakota View Post
    its weird because if i restore with the same backup files and sql to my test server wamp it works fine. but restoring to my web host crazydomains i get these auto_increment issues and cant add more than one attribute
    Can give much help, but has you've have guess it, there's a ID that's already there.
    If you say in your wamp you can restore a backup and it works ok, something is wrong with that table.
    Don't even know why a products_attributes_id would be "0" , if fact It should be auto incremented. But I'm not a expert.

    I would try to export to csv that table from wamp and your domain and compared then. There's has to be something duplicated.

    And after you restore in wamp, you can insert new stuff ?
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    You could try installing the myDEBUG Backtrace plugin (https://www.zen-cart.com/downloads.p...file&id=1879); that will let you (and us) know who is making the malformed call to insert that attribute record.

    When/if you do post the generated log, be aware that your admin's secret folder name will appear as part of the data. You'll want to xxx that information out so that the world doesn't know your admin folder's name.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    If understand the discussion, action, and results correctly, the socalled malformed query is in admin/attributes_controller.php beginning at line 311:

    Code:
     $db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_attributes_id, 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 (0,
                                      '" . (int)$products_id . "',
                                      '" . (int)$options_id . "',
                                      '" . (int)$values_id . "',
                                      '" . (float)zen_db_input($value_price) . "',
                                      '" . zen_db_input($price_prefix) . "',
                                      '" . (int)zen_db_input($products_options_sort_order) . "',
                                      '" . (int)zen_db_input($product_attribute_is_free) . "',
                                      '" . (float)zen_db_input($products_attributes_weight) . "',
                                      '" . zen_db_input($products_attributes_weight_prefix) . "',
                                      '" . (int)zen_db_input($attributes_display_only) . "',
                                      '" . (int)zen_db_input($attributes_default) . "',
                                      '" . (int)zen_db_input($attributes_discounted) . "',
                                      '" . zen_db_input($attributes_image_name) . "',
                                      '" . (int)zen_db_input($attributes_price_base_included) . "',
                                      '" . (float)zen_db_input($attributes_price_onetime) . "',
                                      '" . (float)zen_db_input($attributes_price_factor) . "',
                                      '" . (float)zen_db_input($attributes_price_factor_offset) . "',
                                      '" . (float)zen_db_input($attributes_price_factor_onetime) . "',
                                      '" . (float)zen_db_input($attributes_price_factor_onetime_offset) . "',
                                      '" . zen_db_input($attributes_qty_prices) . "',
                                      '" . zen_db_input($attributes_qty_prices_onetime) . "',
                                      '" . (float)zen_db_input($attributes_price_words) . "',
                                      '" . (int)zen_db_input($attributes_price_words_free) . "',
                                      '" . (float)zen_db_input($attributes_price_letters) . "',
                                      '" . (int)zen_db_input(
    As previously pointed out the auto-increment ought to assign a new value other than 0 to the attribute_id, but there are some servers that are not setup to do that with a value of zero presented... Two solutions I see, either find all such assignments in all queries and either attempt to use null instead or remove such an assignment or work with your host to have them adjust or help you to adjust the mysql settings so that auto_numbering can't start on 0 but instead 1.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Feb 2016
    Posts
    58
    Plugin Contributions
    0

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    thank you mate this would seem to best answer kinda the track i was going down but haven't had much luck in working it out i even tried rolling site back to a few weeks ago and same issue my backups don't go back that far as i cleaned them out wops> but i don't think a restore will fix it as like you say some hosting servers don't like 0 and wont auto-increment and yet my test server running wamp with updated phpmyadmin will auto-increment fine no problems is defiantly a hosting sql issue with auto-increment 0 . seems strange as the crazy-domains hosting support zencart and have auto installer on there site surely they must know this is a issue. ill keep digging and try have a play with the database see what i can do wish me luck and thanks for the reply's i don't want to lose my site

  7. #7
    Join Date
    Feb 2016
    Posts
    58
    Plugin Contributions
    0

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    also should i be using this check box when importing my database in phpmyadmin <Do not use AUTO_INCREMENT for zero values> has this caused the issue i was told it should be check also using this option on my test server everything works fine so i guess its fine just seem to sound very much like the issue lol

  8. #8
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    mydakota,

    This FAQ outlines what should be checked for a "good" database backup
    https://www.zen-cart.com/content.php...atabase-backup
    Zen-Venom Get Bitten

  9. #9
    Join Date
    Feb 2016
    Posts
    58
    Plugin Contributions
    0

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    ok so in this dose not say anything about CHECKED: Add AUTO_INCREMENT value as in the older versions of phpmyadmin but say Settings not mentioned can be left to their defaults. and this option Add AUTO_INCREMENT value is by default checked so i assume its correct. but to me i sounds suspect to the error i get

    Using phpMyAdmin v3.4 or higher:
    The ideal settings to do a backup via phpMyAdmin are shown below. Settings not mentioned can be left to their defaults.
    You will be presented with a choice of "Quick Backup" or "Custom", CHOOSE "Custom", and then make the following selections:
    - Output: - Save output to a file, leave all the other settings under Output as defaults, except maybe Compression:
    OPTIONAL: - Compression: "gzipped" (or whatever you prefer... gzip makes smaller files, but zip files are easier to read on Windows computers)
    - Format: - SQL
    - Format-specific options: - You ONLY need to check the "structure and data" option.
    - Object creation options: - check ALL the boxes in this section, except the "Add CREATE DATABASE / USE statement" option.
    - Data dump options: - choose "INSERT" from the pulldown, and check the "both of the above" option. The rest of the defaults are fine.

  10. #10
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: PHP Fatal error: 1062uplicate entry '0' for key 'PRIMARY'

    - CHECKED: Add AUTO_INCREMENT value
    This is listed in v3.3 or lower
    Zen-Venom Get Bitten

 

 
Page 1 of 4 123 ... LastLast

Similar Threads

  1. Replies: 3
    Last Post: 21 Jan 2016, 10:35 PM
  2. v151 PHP Fatal error 1062: Duplicate entry '2147483647' for key 1
    By NoobGal in forum General Questions
    Replies: 5
    Last Post: 20 Jan 2013, 05:36 PM
  3. Replies: 2
    Last Post: 11 Dec 2012, 03:58 AM
  4. v151 PHP Fatal error:1062:Duplicate entry '1-1' for key 'PRIMARY'
    By Dopefish in forum General Questions
    Replies: 14
    Last Post: 19 Oct 2012, 02:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR