LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-07-2012, 09:32 PM   #1
sureshv120
LQ Newbie
 
Registered: Feb 2012
Posts: 1

Rep: Reputation: Disabled
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-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
 
Old 02-08-2012, 04:26 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,061
Blog Entries: 3

Rep: Reputation: 237Reputation: 237Reputation: 237
Do you know what character set the google API uses? That would be a good first step to find out...

Also, what headers are you sending with the page? You should send a character set header (and it should be 'utf-8' based on your code), plus you can use a
Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
in the HTML.

Hope this helps,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP not displaying utf-8 characters from mysql goossen Linux - Software 1 02-08-2011 07:32 AM
How can I type characters that aren't in my Spanish keyboard? DeeDeeRamone Linux - General 2 10-16-2008 06:43 PM
Spanish accented characters in an English keyboard (Xubuntu)? joseantmm Ubuntu 2 01-23-2007 09:04 AM
Fedora Spanish Characters - a new twist: mySQL jjdoll42 Linux - Software 1 05-19-2005 02:28 PM
Print Spanish Characters in Epson FX-850 blas Linux - General 0 01-29-2004 12:56 PM


All times are GMT -5. The time now is 06:24 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration