Unix Technical Forum

Charset driving me crazy!

This is a discussion on Charset driving me crazy! within the MySQL forums, part of the Database Server Software category; --> Hello! This is driving me crazy. I use php to query MySQL. Then the results are displayed on a ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:14 AM
correo@ironcito.com
 
Posts: n/a
Default Charset driving me crazy!

Hello!

This is driving me crazy. I use php to query MySQL. Then the results
are displayed on a webpage. All accented characters, umlauts, etc. are
displayed incorrectly on the webpage. I included "echo
mysql_client_encoding();" in the php script and it says the charset is
latin1_swedish_ci. However, both phpMyAdmin and Navicat say that ALL
charsets are set to UTF8 at the server, database and table level. Where
is this damn latin1 charset coming from? Any help will be appreciated.
Thanks in advance.

Diego

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 07:14 AM
Axel Schwenke
 
Posts: n/a
Default Re: Charset driving me crazy!

correo@ironcito.com wrote:
>
> This is driving me crazy. I use php to query MySQL.


What MySQL version do you use? What is the (default) character set
(and collation) at server/database/table/column level?

Which PHP extension do you use to connect to MySQL? The old 'mysql'
extension does not know about character sets. Maybe you would like
to switch to the (newer, better, bigger) 'mysqli' extension.

> Then the results are displayed on a webpage.


Do you set a 'content-type' header with character set information?
What encoding do you use to store the data?

> All accented characters, umlauts, etc. are
> displayed incorrectly on the webpage.


> both phpMyAdmin and Navicat say that ALL
> charsets are set to UTF8 at the server, database and table level.


What does the database say (SHOW VARIABLES LIKE 'char%', SHOW CREATE
TABLE ..., SHOW CREATE DATABASE ...)? More important - does your
MySQL client specify a connection character set?

Last not least: have you read the chapter on character set and
collation support in MySQL?


Fast recipe to avoid character set problems:

1. store all strings in UTF8 encoding
2. connect to the database with UTF8 connection setting
3. emit a content-type header specifying UTF8 encoding


XL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 07:14 AM
Kirk Kimmel
 
Posts: n/a
Default Re: Charset driving me crazy!

Just as a side note. Apache by default encodes it's served web pages as
latin1. That might be how your pages are coming out in the wrong
encoding. That is if you are using apache.

Kirk

correo@ironcito.com wrote:
> Hello!
>
> This is driving me crazy. I use php to query MySQL. Then the results
> are displayed on a webpage. All accented characters, umlauts, etc. are
> displayed incorrectly on the webpage. I included "echo
> mysql_client_encoding();" in the php script and it says the charset is
> latin1_swedish_ci. However, both phpMyAdmin and Navicat say that ALL
> charsets are set to UTF8 at the server, database and table level. Where
> is this damn latin1 charset coming from? Any help will be appreciated.
> Thanks in advance.
>
> Diego
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:50 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com