CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Foreign key restraint fails
Pages: [1]

Author Topic: Foreign key restraint fails  (Read 2086 times)

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Foreign key restraint fails
March 28, 2008, 08:23:51 am
Using PayPal Sandbox - this is what I get on the final submission for a test payment. I've seen a lot of posts referencing "foreign key restraint" - what gives? If somebody could give me explicit instructions if there's database manipulation involved that would be spectacular; I'm a designer, not a coder. Thank you much in advance for your help - the whole installation process has been pretty unbearable, but I'm hoping it will be worth it in the end. Thanks much!

   Sorry. A non-recoverable error has occurred.

    Database Error Code: Cannot add or update a child row: a foreign key constraint fails, 1216

    Return to home page.

Error Details:
Code: [Select]
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  102 , 'civicrm_contact,102' ,  102 ,  20080328104946 )  [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  102 , 'civicrm_contact,102' ,  102 ,  20080328104946 )  [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  102 , 'civicrm_contact,102' ,  102 ,  20080328104946 )  [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]"]
)

[/code]

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Foreign key restraint fails
March 28, 2008, 09:55:13 am
This error is usually related to updating / reloading the CiviCRM DB while remaining logged in to Drupal. The contact_id in your session (102 in this case) is no longer a valid contact record due to DB changes.

You should be able to simply logout and log back in. But to be safe I would truncate (delete all records) from the Drupal sessions table.
Protect your investment in CiviCRM by  becoming a Member!

bcobin

  • I post frequently
  • ***
  • Posts: 337
  • Karma: 9
    • InterCreative Media
  • CiviCRM version: 4.3.3
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.9
  • PHP version: 5.3
Re: Foreign key restraint fails
March 28, 2008, 10:14:26 am
Thank you - thank you! You were, indeed, correct. Hopefully this will be the last of the "speed bumps" - many thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Foreign key restraint fails

This forum was archived on 2017-11-26.