Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- MySQL 4.1 / PHP 5.0 : Unicode problems
October 20, 2006, 10:42 am
rate this thread
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
Please help, I have been stuck on this for days now.
Re: MySQL 4.1 / PHP 5.0 : Unicode problems
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.