mysql_query question

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
CapriSkye
Regular
Posts: 119
Joined: Sun Oct 31, 2004 4:42 am
Location: Taiwan
Contact:

mysql_query question

Post by CapriSkye »

i have my old blog using old php and mysql version, and mysql with utf-8 encoding.
now i'm testing latest php and mysql version, then import my old s9y database to the new one, but my chinese entries are all messed up.
then i add this line
@mysql_query("SET NAMES UTF8");
to /include/db/mysql.inc.php and everything works out so far.

so my question is how do i use SET NAMES UTF8 as default when installing mysql?
that way I don't have to add that line to mysql.inc.php.
maybe add something to my.ini but i don't know what is the correctly syntax.
it seems stranage that i have to use SET NAMES when the default character set is already utf-8. anybody have experience with this?
thanks
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: mysql_query question

Post by garvinhicking »

You can change that in the my.cnf file, yes. Please look that up in the MySQL documentation...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
CapriSkye
Regular
Posts: 119
Joined: Sun Oct 31, 2004 4:42 am
Location: Taiwan
Contact:

Post by CapriSkye »

the manual says having default-character-set in option file is sufficient, but that doesn't do it.
i still have to add SET NAMES to mysql.inc.php to make it work correctly.
when checking the status of mysql server, both client and connection character set are latin1, when default-character-set is set to utf-8.
i can change client and connection to utf-8 using the command line, but restart would reset them back to latin1.
i've read some articles related to this and they all suggest running SET NAMES before mysql_query, so i guess that's the only way to go.
thanks
Post Reply