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) »
  • Problem with contribution from OverSeas
Pages: [1]

Author Topic: Problem with contribution from OverSeas  (Read 3218 times)

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Problem with contribution from OverSeas
August 12, 2008, 06:33:14 am
We get contributions from many countries, but for some reason, this donor and Thailand is unable to donate despite our many attempts to help him do it.  We have Thailand enabled in the country and state tables.... ?

Test Test-User
111 South Island
Bangkok, 18 10110
TH



    Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`fpwr_civicrm20/civicrm_address`, CONSTRAINT `FK_civicrm_address_state_province_id` FOREIGN KEY (`state_province_id`) REFERENCES `civicrm_state_province` (`id`) ON DELETE SET NULL), 1452

    Return to home page.

Error Details:

Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => UPDATE  civicrm_address  SET contact_id = 259 , location_type_id = 5 , is_primary = 0 , is_billing = 0 , street_address = '111 South Island' , city = 'Bangkok' , state_province_id = 18 , postal_code = '10110' , country_id = 1211 , geo_code_1 = 13.670304 , geo_code_2 = 100.637435   WHERE (  civicrm_address.id = 1743 )   [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`fpwr_civicrm20/civicrm_address`, CONSTRAINT `FK_civicrm_address_state_province_id` FOREIGN KEY (`state_province_id`) REFERENCES `civicrm_state_province` (`id`) ON DELETE SET NULL)]
    [type] => DB_Error
    [user_info] => UPDATE  civicrm_address  SET contact_id = 259 , location_type_id = 5 , is_primary = 0 , is_billing = 0 , street_address = '111 South Island' , city = 'Bangkok' , state_province_id = 18 , postal_code = '10110' , country_id = 1211 , geo_code_1 = 13.670304 , geo_code_2 = 100.637435   WHERE (  civicrm_address.id = 1743 )   [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`fpwr_civicrm20/civicrm_address`, CONSTRAINT `FK_civicrm_address_state_province_id` FOREIGN KEY (`state_province_id`) REFERENCES `civicrm_state_province` (`id`) ON DELETE SET NULL)]
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPDATE  civicrm_address  SET contact_id = 259 , location_type_id = 5 , is_primary = 0 , is_billing = 0 , street_address = '111 South Island' , city = 'Bangkok' , state_province_id = 18 , postal_code = '10110' , country_id = 1211 , geo_code_1 = 13.670304 , geo_code_2 = 100.637435   WHERE (  civicrm_address.id = 1743 )   [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`fpwr_civicrm20/civicrm_address`, CONSTRAINT `FK_civicrm_address_state_province_id` FOREIGN KEY (`state_province_id`) REFERENCES `civicrm_state_province` (`id`) ON DELETE SET NULL)]"]
)
Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem with contribution from OverSeas
August 12, 2008, 11:32:26 am
Hi Jeff - The query is trying to use  a value of 18 as the state_province_id. This is strange since all the civicrm_state_province tables I've seen (and the SQL for populating them) have id values starting with 1000. I enabled Thailand Country / State on the 2.0 demo and went to a Contribution Page. As expected the Thai provinces in the State / Province <select> had values in the 4,000 range.

Snippet from HTML on http://drupal.demo.civicrm.org/civicrm/contribute/transact?reset=1&action=preview&id=1:
Code: [Select]

        <option value="">- select -</option>
<option value="1000" selected="selected">Alabama</option>
<option value="1001">Alaska</option>
<option value="1100">Alberta</option>
<option value="1052">American Samoa</option>
<option value="4631">Amnat Charoen</option>
<option value="4632">Ang Thong</option>
Protect your investment in CiviCRM by  becoming a Member!

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 11:51:40 am
So how do we fix?  Reload all of those reference tables?
Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem with contribution from OverSeas
August 12, 2008, 12:33:48 pm
First question is - where is that value of 18 coming from. What State / Province field(s) does your contribution form have in it? Billing fields for PayPal pro and/or a profile?

What values do u see when viewing source for that field or fields?

Does the value for the donor's Thai state on the form match what's in your civicrm_state_province table? It should ...(regardless of whether it's the same as my / our values).
Protect your investment in CiviCRM by  becoming a Member!

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 02:56:53 pm
Its coming from the "abbreviation" field in the state_province table. 
Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with contribution from OverSeas
August 12, 2008, 03:21:31 pm

arghhhhhhh

the easiest short term fix for this is to replace the abbreviation in the state_provicne table for all records that have Thailand (country_id = 1211) to something non numeric. You'll want to do this for all the 77 'thai states/provinces' that we have in the DB

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 03:35:23 pm
More on this - by changing the "abbreviation" for the "Chai-Nat" province of Thailand from "18" to its state_province_id of 4635, we got past this error.  However, we get a "10536:Invalid Data" error from PayPal because I am sure that PP doesn't recognize 4635 as an accurate province?

Anyways, if you can point us to the code where id and abbreviation are being switched, we can attempt to fix it.

Jeff


Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with contribution from OverSeas
August 12, 2008, 03:48:24 pm

check: http://paypal.lithium.com/pdn/board/message?board.id=sandbox&thread.id=9735

you might want to start a new transaction

i'll have an issue (http://issues.civicrm.org/jira/browse/CRM-3393) and a partial hacky fix for this in 2.1 in the next few hours/days. You can watch that issue and backport the fix

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 03:56:55 pm
I am not that worried about the PP error. 

I am wondering more so why the system appears to be using the "abbreviation" as the state_province_id - which for Thailand is causing us not to be able to accept donations.


Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 04:02:27 pm
Oh, and if your hack works - great - we plan to upgrade to 2.1 as soon as we can - thanks


Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with contribution from OverSeas
August 12, 2008, 04:22:15 pm

jeff:

Can you reproduce this issue either on sandbox or on demo? You can probably use pay later to bypass the payment processor

I cant seem to reproduce this on my local install

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with contribution from OverSeas
August 12, 2008, 04:28:56 pm

I was able to reproduce this with paypal pro. Also tested my fix which is hackish but works :)

its now checked in and part of 2.1

You can get the patch here: http://fisheye.civicrm.org/changelog/CiviCRM/trunk?cs=16610

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 07:42:49 pm
you rock - we will try it - thanks
Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
Re: Problem with contribution from OverSeas
August 12, 2008, 07:53:18 pm
Lobo,

Question - is it in the plans (or would it be hard) to only show the state _provinces in the drop-down based on the country chosen ?

Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with contribution from OverSeas
August 12, 2008, 07:59:56 pm

We will expose the state-country widget to front end pages in a future 2.x release.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Problem with contribution from OverSeas

This forum was archived on 2017-11-26.