Page 1 of 1

Is there a utf8 bug with mysql_fetch_array()

Posted: Sun Feb 04, 2007 9:30 pm
by zebra
I am using MySQL 4.1.22. and PHP 4.4.4.

Now, when I add the following 2 lines of code, mysql_query() works perfectly with utf8 charset:
mysql_query("SET CHARACTER SET utf8", $db);
mysql_query("SET NAMES 'utf8'", $db);




However, results for mysql_fetch_array() appears like (????????).



I'd search google for a solution but was unable to find one. If it is really a bug with mysql_fetch_array(), how can I rewrite mysql_fetch_array() to use mysql_query() instead?

Posted: Sun Feb 04, 2007 9:50 pm
by feyd
Are your pages telling the browser they are outputting utf8 streams?

Posted: Mon Feb 05, 2007 11:06 pm
by zebra
Yes,
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
is declared and mysql_query() works perfectly.

Thanks for your assistance.

Posted: Mon Feb 05, 2007 11:07 pm
by feyd
So you're not calling header() with a content type?

Posted: Tue Feb 06, 2007 6:56 am
by zebra
No, I wasn't using header. But I added header('Content-Type: text/html; charset=UTF-8'); like you suggested.

The result is still ???? for mysql_fetch_array().
but works perfectly for mysql_query()

Posted: Tue Feb 06, 2007 12:14 pm
by AKA Panama Jack
MySql 4 isn't that great on UTF8 support. You may not have the approriate character installed for MySql to store and retrieve the data properly.

http://dev.mysql.com/doc/refman/4.1/en/ ... ation.html

MySql 5 remedied this problem has very robust UTF8 support. If you can upgrade your server you should.