Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-08-2012 #1Just Joined!
- Join Date
- Feb 2012
- Posts
- 1
Problem with spanish characters while using Google API, PHP, MySql
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-
(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
- 02-09-2012 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,163
Well, I think that this is not a Fedora/Red Hat issue, but a MySQL/PHP problem. Normal Spanish characters should be handled OK in UTF-8. I sometimes set my system to use Spanish characters since half my extended family is from Mexico so from time to time I have to send emails and such in Spanish, with the correct accents on the letters, otherwise my relatives who don't read/write English would have problems...
However, I haven't stored such data in MySQL databases (Oracle, yes - no problem there), so I'm at the limits of my knowledge about this.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
