#41957 [Bgs->Opn]: utf8 data appears to become ascii after mysql_query/mysql_fetch_row
| From: | jhala at uoregon dot edu | Date: | Thu, 12 Jul 2007 07:00:11 +0000 |
| Subject: | #41957 [Bgs->Opn]: utf8 data appears to become ascii after mysql_query/mysql_fetch_row | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114955@lists.php.net to get a copy of this message | ||
ID: 41957
User updated by: jhala at uoregon dot edu
Reported By: jhala at uoregon dot edu
-Status: Bogus
+Status: Open
Bug Type: MySQL related
Operating System: Vista/Fedora 7/WinXP
PHP Version: 5.2.3
New Comment:
I beg to differ. I have eliminated all other possible explanations.
The only remaining explanation, however improbable, is that this is a
bug. If you think I'm wrong, have me try something new. I have googled
and posted everywhere I can think, and nobody has a solution that I have
not seen or tried.
Previous Comments:
------------------------------------------------------------------------
[2007-07-10 21:51:36] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2007-07-10 21:41:48] jhala at uoregon dot edu
Description:
------------
I have a fully UTF-8 MySQL database with a fully UTF-8 table. I have a
php page which has "<meta http-equiv="content-type"
content="application/xhtml+xml; charset=utf-8" />" at the top of the
html section and "mysql_set_charset("utf8");" after my connection. 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"
and mysql_client_encoding(); reports "utf8".
Reproduce code:
---------------
$con = mysql_connect('localhost', 'user', 'password');
mysql_select_db("database", $con);
mysql_set_charset("utf8");
$query = "SELECT japanese_terms.term_lang, language_en FROM
japanese_terms, languages ";
$query .="WHERE japanese_terms.term_id = languages.language_id ORDER BY
term_id";
$result = mysql_query($query);
while( $row = mysql_fetch_row($result))
{
foreach($row as $field)
{ print($field . "<br />"); }
}
Expected result:
----------------
I expect the UTF-8 data to display properly, and as UTF-8 data. When I
run the same query that pulls out (in this case, Japanese, but say any)
UTF8 data, it displays properly in MySQL Query Browser.
Actual result:
--------------
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" instead of
expected "UTF-8".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41957&edit=1