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) »
  • two questions related to my contribution page
Pages: [1]

Author Topic: two questions related to my contribution page  (Read 1886 times)

vijai

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
two questions related to my contribution page
June 13, 2008, 07:43:00 am

a) I have some addresses which do not have a state/province

How can I add to the list of states/provinces (I want to add 'None')?

b) Users have reported this error :

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

Error Details:
Array(    [callback] => Array        (           
  • => CRM_Core_Error            [1] => handle        )     
    Code: [Select]
    => -3    [message] => DB Error: constraint violation    [mode] => 16    [debug_info] => INSERT INTO civicrm_address (location_id , street_address , city , state_province_id , postal_code , country_id ) VALUES ( 4131 , 'P.O. Box 1046' , 'Kingston 8' ,  01 , '8' ,  1108 )  [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]    [type] => DB_Error   [/li]


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: two questions related to my contribution page
June 13, 2008, 11:41:06 am

1. You can go into mysqladmin and add to the civicrm_state_province table

2. the state_province_id is a an invalid FK. the value is 01 (not sure how they managed to get this id). In default CiviCRM the ids start from 1000 in that table

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

vijai

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: two questions related to my contribution page
June 13, 2008, 12:13:17 pm
happens when I select city as 'kingston' and state as 'kingston'

the actual address does not have a state in it so its default behavior for users to select 'kingston' as the state

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

       
Code: [Select]
=> -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => UPDATE  civicrm_address  SET location_id = 92 , street_address = 'P.O. Box 1046' , city = 'kingston' , state_province_id = 01 , postal_code = '8' , country_id = 1108   WHERE (  civicrm_address.id = 91 )   [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]
    [type] => DB_Error
    [user_info] => UPDATE  civicrm_address  SET location_id = 92 , street_address = 'P.O. Box 1046' , city = 'kingston' , state_province_id = 01 , postal_code = '8' , country_id = 1108   WHERE (  civicrm_address.id = 91 )   [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="UPDATE  civicrm_address  SET location_id = 92 , street_address = 'P.O. Box 1046' , city = 'kingston' , state_province_id = 01 , postal_code = '8' , country_id = 1108   WHERE (  civicrm_address.id = 91 )   [nativecode=1216 ** Cannot add or update a child row: a foreign key constraint fails]"]
)

vijai

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: two questions related to my contribution page
June 13, 2008, 01:32:38 pm
ok, it looks like the issue is with the 30 odd states with '01' as their abbreviation

I changed them all to characters and it seems to work

I cant file an issue on the sandbox because it only allows american states


vijai

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: two questions related to my contribution page
June 13, 2008, 02:47:15 pm
can I remove the state option completely? if so, where?

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: two questions related to my contribution page
June 13, 2008, 03:35:23 pm

CRM/Core/Payment/Form.php, function buildCreditCard

I'm not sure of the implications are downstream of removing the state field (i dont think there will be any). You might need to check that your payment processor does not require a state field

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

vijai

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: two questions related to my contribution page
June 18, 2008, 11:07:36 am
Hi,

It looks like any state with a digit in its abbreviation will result in a foreign key error. I replaced them all with dummy values and I have had no problems since.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • two questions related to my contribution page

This forum was archived on 2017-11-26.