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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Still having problems with a special character
Pages: [1] 2

Author Topic: Still having problems with a special character  (Read 5506 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Still having problems with a special character
April 07, 2009, 02:27:17 am
In an earlier post I have mentioned that I am having problems with the contact_add API. It does not process special characters correctly. I am trying to add a person with the name José Brinkman as follows:
Code: [Select]
$params = array(
                    'first_name'    => 'José',
                    'last_name'     => 'Brinkman',
    'middle_name'   => $tussenvoegsel,
                    'contact_type'  => 'Individual',
    'job_title' => $functie,
    'gender_id' => $gender,
    'prefix_id' => $prefix,
    'birth_date'    => $birthdate,
    'dupe_check'    => 'true'
                    );

// Aanroepen CiviCRM API functie om contact toe te voegen:
$contact =&civicrm_contact_add( $params );
In the database I end up with a person with the name 'Jos Brinkman'. On my post I had one reply, stating that the function performed wonderfully on his machine. I understand that the function works OK, but it does not help me in my search for a solution  ;D

I have tried a number of things:
  • I have checked the values of the parameters in the API, and it contains the value 'José' before the API calls itself with the right parameter values. I am not sure where I can find the actual INSERT statement to check there? As far as I can see though everything is OK here.
  • I have added a person with the name "José" in CiviCRM and it processes OK.
  • I have checked the character sets for my MYSQL tables, and they all have ÚTF8' so that seems to be OK....
I am lost, is there anyone who can point me in a direction?
Regards
Erik
« Last Edit: April 07, 2009, 02:31:37 am by Erik Hommel »
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Still having problems with a special character
April 07, 2009, 02:43:48 am
Erik,

One thing that comes to my mind is to check the mysql client connection encoding that you are using when invoking your script. Check around mysql_client_encoding and mysql_set_charset in PHP and default-character-set setting in [client] section in my.ini if you have control over your mysql install.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 03:10:49 am
I will have a look at that, thanks for the help!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 04:20:58 am
I checked the mysqli_client_encoding and it turned out to be 'latin1' whilst my database was 'utf8'. So I used mysqli_set_character_set to change itto utf8. The result is still the same though.   :(
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 04:35:50 am
I think I have been silly....I tested with a connection to MySQL I made myself, but I need to use the connection that CiviCRM uses. How do I access that connection? Can I find it somewhere in the civicrm.settings?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Still having problems with a special character
April 07, 2009, 04:59:45 am

Hey,

First of all - how come you're using CiviCRM 2.2.4? This version is not out yet - I don't think it's even on the roadmap yet. ;-)

You might be hitting some potential bug with the way API handles encoding (although I will be surprised if that's an actual error in CiviCRM). Try running those two queries from your script:

SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';

and let me know what're the results.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 05:01:21 am
I wa using 2.2.4 beta....................... ;)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Still having problems with a special character
April 07, 2009, 05:12:38 am
Just to avoid confusion, the name of the version is 2.2.beta4. ;-) You're four versions behind, would be good to upgrade to 2.2.2. :-)

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 05:13:31 am
Thanx for the tup, and I know.....it is on my to do list!!!!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 05:17:30 am
OK, the SHOW VARIABELE results are:
utf8 for the character_set%
utf8_general_ci for the collation%

that looks OK though, doesn't it? This is fairly deep for me so I am not sure :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Still having problems with a special character
April 07, 2009, 06:31:07 am
Hm, now I'm scratching my head.

Tried adding contact via API on trunk code, using the array you pasted before and it works ok on my install.

Just to make sure that everything is fine with mysql encodings, can you put in following piece of code into your script, execute and paste results here?

Code: [Select]
require_once 'CRM/Core/DAO.php';
$dao =& new CRM_Core_DAO( );
$dao->query( "SHOW VARIABLES LIKE 'character_set%';" );
while( $dao->fetch( ) ) {
print_r( $dao->Variable_name . "\n" );
print_r( $dao->Value . "\n\n" );
}

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 07, 2009, 08:07:15 am
In the meantime I have upgraded to 2.2.2  :)

the result of the script:
character_set_client utf8
character_set_connection utf8
character_set_database latin1
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
character_sets_dir c:\wamp\bin\mysql\mysql5.1.30\share\charsets\

The problem occurs on my localhost, but also on our own demo site....

Thanks for your support
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 08, 2009, 07:09:06 am
From my previous post I would imagine I change the character set for the database and the server to be utf8 also, is that correct?
And can someone explain to me why this only causes a problem when I go through the API and NOT when I update in CiviCRM itself or directly in the MySQL database?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.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: Still having problems with a special character
April 08, 2009, 08:12:45 am

so the API and CiviCRM basically call and initialize the DB in very similar manner. So kinda wierd that there is an issue with calling stuff via the API and not via the UI :(

Do you have mysql query logging enabled? if so, can you please enable it and see what queries are issued at the start of the db initialization. One of the initial queries should be:  /*!40101 SET NAMES utf8 */

thanx

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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Still having problems with a special character
April 08, 2009, 08:16:58 am
I do not have MySQL logging enabled. I use MySQL Administrator and this is not enabled for my localhost, I thought this was due to Wampserver, but that is just a wild guess.........way over my head  :)

How can I enable MySQL logging?

Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Still having problems with a special character

This forum was archived on 2017-11-26.