Jump to content

Problem with spanish characters while using Google API, PHP, MySql


sureshv120

Recommended Posts

Hello Sir/Maam,

 

I need some help in a problem I am having with spanish special characters. A brief summary of what I am doing first. I have written a PHP script which fetches data from Google Spreadsheet using Zend Google PHP API. This data is then put into MySql database.

 

$row=$Col->getText(); //getText is the Google API that returns the value in the row.

print "$row"; // I print the content

 

But the problem is that some spanish characters such as ñer appear as ñer. Later on in the PHP code I go on to save these values in MySql. And even in the tables the same problem.Don't know where the problem is.

 

I tried various different things such as edit the PHP file and add:

 

mbstring.language              = Neutral      ; Set default language to Neutral(UTF-8) (default)

mbstring.internal_encoding      = UTF-8        ; Set default internal encoding to UTF-8

mbstring.encoding_translation  = On            ;  HTTP input encoding translation is enabled

mbstring.http_input            = auto          ; Set HTTP input character set dectection to auto

mbstring.http_output            = UTF-8        ; Set HTTP output encoding to UTF-8

mbstring.detect_order          = auto          ; Set default character encoding detection order to auto

mbstring.substitute_character  = none          ; Do not print invalid characters

default_charset                = UTF-8        ; Default character set for auto content type header

mbstring.func_overload  = 7 ; All non-multibyte-safe functions are overloaded with the mbstring alternatives

 

Add in the below in MySql

 

init_connect='SET collation_connection = utf8_unicode_ci; SET NAMES utf8;'

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake

 

Change Database and Table properties

 

ALTER DATABASE db_name

CHARACTER SET utf8

DEFAULT CHARACTER SET utf8

COLLATE utf8_general_ci

DEFAULT COLLATE utf8_general_ci

;

 

ALTER TABLE tbl_name

DEFAULT CHARACTER SET utf8

COLLATE utf8_general_ci

;

 

Call SETNAMES etc just after mysql open connection.

 

$q="SET NAMES 'utf8'";

$r=mysql_query($q);

mysql_query("SET CHARACTER SET utf8");

 

But nothing seems to work. Please help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.