PHP/MySQL UTF-8 SNAFU
Date: 07/10/07
(Web Development) Keywords: php, mysql, browser, html, database, sql
Ok, so I have a fully UTF-8 MySQL database with a fully UTF-8 table. I have a php page which has "" at the top of the html section and "mysql_set_charset("utf8");" after my connection (it's php 2.2.3, so that's more or less the same as "mysql_query("SET NAMES 'utf8'");). I have all my php.ini mbstring stuff configured for utf-8:
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.encoding_translation = On
mbstring.detect_order = auto
and for what it's worth, echo mb_internal_encoding(); reports "UTF-8".
when I run a query that pulls out (in this case, Japanese, but say any) UTF8 data, it displays properly in MySQL Query Browser. With php in the above context however, it does not. Instead, it prints a ? corresponding to each character. When I use mb_detect_encoding(); on each such string, it tells me they are encoded as ASCII. The nearest I can tell is that somewhere between using mysql_query() and mysql_fetch_row(), things got messed up. Is this a bug? Is there something I'm missing? Any clues? Help!
Source: http://community.livejournal.com/webdev/420578.html