I also had this problem...it's been awhile since I dealt with this, but the
solution from Eby should work for you. I wanted to make sure that
'character_set_connection' defaulted to utf8 so that we didn't have to
modify our PHP scripts, but the best solution I found was to change a build
option and recompile the MySQL server, clients and libraries. A quick scan
through the Makefile should turn it up. If I remember correctly, PHP was
pulling the connection character set from the MySQL libraries, and we
weren't able to change the value using mysql.conf. Regardless, recompiling
on the DB and web servers worked for us.
Jason
-----Original Message-----
From: Code for Libraries [mailto:[log in to unmask]] On Behalf Of Ryan
Eby
Sent: Tuesday, April 10, 2007 1:11 PM
To: [log in to unmask]
Subject: Re: [CODE4LIB] Unicode from MySQL display problem
Don't have experience but a search showed that you may have to set-up
your mysql connection from PHP to use utf8 as php isn't good with
unicode. They recommended this:
$result = mysql_query('SET NAMES utf8;');
$result = mysql_query('SET CHARACTER_SET utf8;');
You can apparently also set up your mysql to default all connections
to utf8. Here was where I found it:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/
Q_21957635.html
Eby
On 4/10/07, Andrew Darby <[log in to unmask]> wrote:
> Hello, all. I'm going a little crazy with getting some unicode data
> from MySQL to display properly in a web page, and wondered if you had
> any ideas.
>
> The records are in MySQL (4.1.21) with a utf8_unicode_ci collation.
> When I view in phpmyadmin, everything looks fine. If I run my query
> in phpmyadmin, everything still looks fine, I can cut and paste the
> record into the web page, and it displays fine, but when I grab the
> data from MySQL it conks out:
>
> http://www.ithacalibrary.com/research/unicode_test.php
>
> I assume the problem is with my query or the connection, but I'm not
> sure how I should do it. I've tried explicitly setting the character
> set like so:
>
> SET names = 'utf8_unicodel_ci';
> SET CHARACTER SET 'utf8_unicode_ci'
>
> But this is voodoo to me--just saw it somewhere on the internets.
>
> Am I missing something obvious? Any ideas?
>
> Thanks,
>
> Andrew
>
|