Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2008
    Posts
    9
    Plugin Contributions
    0

    Default #1216 - Cannot add or update a child row: a foreign key constraint fails

    I was importing a backup made with phpmyadmin (latest version of zen cart)

    It works but... it gave me 1 error message on 2 alters:

    #1216 - Cannot add or update a child row: a foreign key constraint fails

    It did not want to do the following 2 alters:

    ALTER TABLE `eav_entity_attribute` ADD CONSTRAINT `FK_EAV_ENTITY_ATTRIBUTE_ATTRIBUTE` FOREIGN KEY ( `attribute_id` ) REFERENCES `eav_attribute` ( `attribute_id` ) ONDELETE CASCADE ON UPDATE CASCADE ,
    ADD CONSTRAINT `FK_EAV_ENTITY_ATTRIBUTE_GROUP` FOREIGN KEY ( `attribute_group_id` ) REFERENCES `eav_attribute_group` ( `attribute_group_id` ) ON DELETE CASCADEON UPDATE CASCADE ;

    I know that a while ago I changed the 2 creation statements of the table to add the constraints on that place.

    Does anybody has seen this before?

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

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    Did you create your backup using the proper settings?
    https://www.zen-cart.com/tutorials/i...hp?article=103
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Jan 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    Yes, I did

    I'm thinking what it was again, I thought it was a BUG in phpmyadmin, in the way it exports

    But google on the error etc... does not give me anything.

    It is simple what phpmyadmin does:

    a) it creates the statement for the table
    b) then inserts
    c) and afterwards the foreign key constraints table alters

    so some of the foreign key table alters will give this error, I thought I read about it somewhere on the mysql forums on the foreign keys.

    So I would have expected to find it here on the forums en masse but searching via search does not give me anything on this.

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

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    I havew not seen this in any ZenCart DB
    Zen-Venom Get Bitten

  5. #5
    Join Date
    Jan 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    ah... I think I have exported the complete database... there is a lot more in there... I think I only need the tables with the zencart prefix...

    anyway if you run into this problem : checking "disable foreign key constraints" while exporting might help.

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

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    I think I only need the tables with the zencart prefix...

    anyway if you run into this problem : checking "disable foreign key constraints" while exporting might help.
    cogmios is online now Report Post Reply With Quote
    And why I linked you to the proper settings for using phpmyadmin to create a proper backup

    https://www.zen-cart.com/tutorials/i...hp?article=103
    Zen-Venom Get Bitten

  7. #7
    Join Date
    Jan 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    I think you should then update that instructions because....

    the checkmark to not check for foreign key restrictions

    ... is NOT on that info page (!) :)

    So... WHEN will that error occur?

    ONLY when you have more than only ZEN in that same database and are restoring all of it. So it is basically an off-topic error for pure zen installations unless you have zen coupled with all other kinds of things and are running it from the same database.
    Last edited by cogmios; 21 Dec 2010 at 07:14 AM.

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

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    the checkmark to not check for foreign key restrictions

    ... is NOT on that info page (!) :)
    I have not seen any phpmyadmin that checks it by default
    Settings not mentioned can be left to their defaults
    Zen-Venom Get Bitten

  9. #9
    Join Date
    Jan 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: #1216 - Cannot add or update a child row: a foreign key constraint fails

    Quote Originally Posted by kobra View Post
    I have not seen any phpmyadmin that checks it by default
    correct but IT MUST BE CHECKED so that it will not check for the foreign key constraints.

 

 

Similar Threads

  1. v154 Problem with update - UPS XML fails
    By semide in forum Addon Shipping Modules
    Replies: 2
    Last Post: 4 Mar 2016, 04:57 PM
  2. Zen Lightbox - Image Size Constraint question
    By Hell Guapo in forum All Other Contributions/Addons
    Replies: 8
    Last Post: 16 Oct 2012, 11:32 AM
  3. Cannot Add or update categories and products
    By sgloeb in forum General Questions
    Replies: 3
    Last Post: 8 Jun 2009, 10:02 PM
  4. Cannot get attribute images to lign up in one row
    By kachana in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 5 Nov 2008, 08:56 PM
  5. Replies: 3
    Last Post: 20 May 2008, 12:22 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