PHP/MySQL output UTF8 Asian characters as question marks?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
PHP/MySQL output UTF8 Asian characters as question marks?
PHP and MySQL are outputting question marks in place of the Asian characters in my MySQL database. I've set the collation to utf8_general_ci. I redid my site's front page and the content is stored in the PHP file along with 27 total different languages all of which display correctly. The files in question are all saved without a BOM (byte order mark) as UTF-8. I can see the Asian characters displaying just fine in phpMyAdmin so I presumed I was missing something in regards to MySQL however I have watched the MySQL queries (with Tail for real time display of all MySQL queries on my PC) and I haven't noticed any syntax that seems unfamiliar...I also tried the utf8_decode function and that didn't do anything. So I'm not really sure what to do at this point other then continue to comb through blog postings, thoughts please?
Re: PHP/MySQL output UTF8 Asian characters as question marks?
Four things to check with text encoding problems:
1. The database table is in the right encoding
2. The PHP file is in the right encoding
3. The HTML output is in the right encoding (check headers and <meta> tags; Firefox's Page Info dialog is very handy for this)
4. The font being used (in the HTML) has those characters
1. The database table is in the right encoding
2. The PHP file is in the right encoding
3. The HTML output is in the right encoding (check headers and <meta> tags; Firefox's Page Info dialog is very handy for this)
4. The font being used (in the HTML) has those characters
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP/MySQL output UTF8 Asian characters as question marks?
The collation of the columns of the table and the table itself is utf8_general_ci.
The PHP files handling the MySQL connection, includes, etc are all UTF-8 without a DOM (Byte Order Mark).
The XML output is encoded as UTF-8.
The font-family is serif which is the same font that the working display of Asian characters is displayed as.
I am just going to manually try to recheck everything I suppose.
The PHP files handling the MySQL connection, includes, etc are all UTF-8 without a DOM (Byte Order Mark).
The XML output is encoded as UTF-8.
The font-family is serif which is the same font that the working display of Asian characters is displayed as.
I am just going to manually try to recheck everything I suppose.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP/MySQL output UTF8 Asian characters as question marks?
AWESOME!
Thanks pytrin!
I added this in addition to the time zone command in the PHP file that allows me to set the time zone...
Thankfully the live server I'm using only required that line as well. I tried both and I think it'll stick with the first line.
I've had a real tug-of-war with trying to figure out if it was PHP or MySQL and that thread completely clarifies things. Thanks again!
Thanks pytrin!
I added this in addition to the time zone command in the PHP file that allows me to set the time zone...
Code: Select all
mysql_query("SET time_zone = '-4:00';");
mysql_query("SET CHARACTER SET 'utf8';");I've had a real tug-of-war with trying to figure out if it was PHP or MySQL and that thread completely clarifies things. Thanks again!
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: PHP/MySQL output UTF8 Asian characters as question marks?
After some testing (and fixing of) Version 2.9's CMS I discovered I needed that second MySQL query to get $_POST of Unicode characters to work correctly...
Code: Select all
mysql_query("SET time_zone = '-4:00';");
mysql_query("SET CHARACTER SET 'utf8';");//GET and POST
mysql_query("SET NAMES 'utf8';");//POST