Forum Moderators: coopster

Message Too Old, No Replies

PHP serves MySQL stored Asian characters as question marks

Have most of my bases covered, what am I missing?

         

JAB Creations

10:52 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have two scenarios...

Works
1.) Asian characters directly stored on a PHP file. The file is saved as UTF-8 without Microsoft's genius BOM (byte order mark) to goof the page up. It's served as application/xhtml+xml as UTF-8 (so really high standards and easy to break though I do this to ensure I code quality) and the characters display just fine. I had to install support for east-Asian languages though even before that Japanese displayed just fine. I have 27 different languages peacefully co-existing on the same page.

Doesn't Work
2.) I have the same string in a MySQL database. When I use phpMyAdmin I can see the string of Asian characters display just fine. However when I make the query to get the information it spits out the XHTML code fine though the Asian characters appear as question marks.

I've set the collation to utf8_general_ci though I'm not sure if there is anything else. I have a real time live feed of all MySQL queries on my local machine and I don't see any MySQL syntax that is unfamiliar with me for the query phpMyAdmin generates to display the data from MySQL. So I presume there is some sort of UTF/Unicode related function in PHP that I am unaware of? Thoughts please?

- John

abidshahzad4u

3:10 pm on Jun 15, 2009 (gmt 0)

10+ Year Member



Use this before generating any content in other languages

header('Content-type: text/html; charset=utf-8');