List:Community« Previous MessageNext Message »
From:Hamid Majidy Date:May 8 2009 7:11am
Subject:RE: Loss of HTML Graphics Characters
View as plain text  
After setting the character set and collation variables consistent with the
working server, the pages still failed to render properly:

SHOW VARIABLES LIKE 'character_set%';
| Variable_name            | Value                      |
| 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       | /usr/share/mysql/charsets/ | 

| Variable_name        | Value             |
| collation_connection | utf8_general_ci   | 
| collation_database   | latin1_swedish_ci | 
| collation_server     | latin1_swedish_ci | 

Also, there's no matches for charset (or char) in the rendered HTML page, in
case the page was asking for a particular non-kosher one.

Finally, removing the lines added after the lines added after PHP connection
to DB corrected the problem:
//mysql_query('SET CHARACTER SET utf8');
//mysql_query('SET NAMES utf8');
//mysql_query('SET COLLATION_CONNECTION utf8');
//mysql_query('SET COLLATION_DATABASE latin1');
Go figure.

Thanks Arjen and MySQL community for the help.

-----Original Message-----
From: Hamid Majidy [mailto:hamid@stripped] 
Sent: Wednesday, May 06, 2009 10:53 PM
To: 'Arjen Lentz'
Cc: 'community@stripped'
Subject: RE: Loss of HTML Graphics Characters

Thank you, Arjen, for your helpful guidance. Unfortunately despite
environment initialization fiddling in the PHP script it still doesn't
render properly. Commands added to the script are:
mysql_query('SET CHARACTER SET utf8');
mysql_query('SET NAMES utf8');
mysql_query('SET COLLATION_CONNECTION utf8');
mysql_query('SET COLLATION_DATABASE latin1');
Many combinations of the above lines tried in the PHP script just after
connecting to MySQL server and mysql_select_db to connect to correct DB with
basically the same result. Page characteristics change as statements are
added and removed, so I know they're taking effect. I see no more errors in
the apache error log, and the weblog sees the request. The page looks best
without any of the new commands. Perhaps explicitly resetting any other
differences in mysql environment variables to match the server where it's
working will fix it. Will try those soon and report back results.


-----Original Message-----
From: Arjen Lentz [mailto:arjen@stripped] 
Sent: Wednesday, May 06, 2009 2:59 PM
To: Hamid Majidy
Cc: community@stripped
Subject: Re: Loss of HTML Graphics Characters

Hi Hamid,

On 07/05/2009, at 2:17 AM, Hamid Majidy wrote:
> Hello MySQL community. I have MySQL 5.0.45 with Apache 2.2.3 running  
> on
> CentoOS 5.2 with a page display issue. Pages display as:
>     Model     Â
> [...]

> Ihave changed DB collation to latin1_swedish_ci on former to match the
> latter DB table’s collation setting. All database and table settings  
> through
> phpAdmin appear identical, yet the two HTML pages rendered on the same
> Windows client machine running the same instance of Firefox appear
> different. I have even dumped the entire table structure and  
> contents from
> one and imported to the other with the same result. HTML contents of  
> the 2
> fields have to be identical after the import. Restarting apache and  
> mysql
> after all the changes did not help either.

Collation has to do with sorting.
What you need to check out is character set (usually utf8 or latin1).

if you are using utf8, you should use something like utf8_general_ci  
as the collation also.
But most importantly, your PHP connection should first set "SET  
NAMES=utf8" as soon as it connects, before doing anything else.
That'll make the connection use utf8 properly without mangling stuff  
that comes out of the db.

Then, there's the character set indicator of your HTML pages  
themselves, a HTML page can indicate which charset it's using; check  
that also.

Arjen Lentz, Director @ Open Query (
Affordable Training and ProActive Support for MySQL & related  

Follow our blog at
OurDelta: free enhanced builds for MySQL @

MySQL Community Mailing List
For list archives:
To unsubscribe:
Loss of HTML Graphics CharactersHamid Majidy6 May
  • Re: Loss of HTML Graphics CharactersArjen Lentz6 May
    • RE: Loss of HTML Graphics CharactersHamid Majidy7 May
  • RE: Loss of HTML Graphics CharactersHamid Majidy8 May