Page 1 of 1

mysql_query question

Posted: Wed Jul 20, 2005 1:30 am
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

Re: mysql_query question

Posted: Wed Jul 20, 2005 11:09 am
by garvinhicking
You can change that in the my.cnf file, yes. Please look that up in the MySQL documentation...

Regards,
Garvin

Posted: Wed Jul 20, 2005 8:02 pm
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