MySQL 4.1 / PHP 5.0 : Unicode problems

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Everyone,

I have been trying to build a website that has multilingual support
using the LAMP setup. I have created tables that store language
information and correlate different strings ids with languages. The
strings are all VARCHAR with unicode (utf8) encoding.

I have tried all the ways that I could think of and I have checked
every website to no avail. What I am trying to do is simply open a
connection to the database (using mysqli) and query the tables for one
unicode string entry. Then I call fetch_object on the result and print
it to an HTML document. This fails with me. The characters I see are
not unicode but either ??????? or some weird character. Aparently the
encoding turns out to be ISO-8859-1.

I have done the following:
1. Create the entries in the MySQL tables as unicode in InnoDB tables.
Unicode text shows up properly in phpmyadmin.
2. Query correctly to the best of my knowledge using mysqli.
3. Add the proper header encoding to the http header and add this meta
tag to the html:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

Everything I have read says that this should work even though PHP is
notorious for unicode support. What I have been able to narrow down the
problem to is that the string that I get back from the database is
latin encoding. I know it is unicode from MySQL (phpmyadmin), so I
assume the problem lies in the mysqli_query function call or with the
fetch_object call.

Please help, I have been stuck on this for days now.


Re: MySQL 4.1 / PHP 5.0 : Unicode problems

Maybe this will help:

mysqli_set_charset('utf8'); wrote:
Quoted text here. Click to load it

Re: MySQL 4.1 / PHP 5.0 : Unicode problems

Yes thanks!!! That did it! Wow, 4 days of debugging for this!

Thanks a lot.

However, i have a problem with my versions. I am running locally on
WAMP 1.6.3 and the function seems to be missing. However on my hosting
server, though they are using an older MySQL database vesion (4.1) with
PHP5, there are no problems. That's how I know it works. All that
remains is to fix this locally for WAMP.


Re: MySQL 4.1 / PHP 5.0 : Unicode problems

If you don't have that function, you could try sending this directly to

    SET NAMES UTF8 wrote:
Quoted text here. Click to load it

Site Timeline