Inserting Japanese into MySQL: It almost works now...

From: Date: Mon, 14 May 2007 08:08:24 +0000
Subject: Inserting Japanese into MySQL: It almost works now...
Groups: php.i18n 
Request: Send a blank email to php-i18n+get-1071@lists.php.net to get a copy of this message
I can get it to work by adding this: --> $query = "SET NAMES 'utf8'"; --> $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $query="INSERT INTO members (username, password, name, email, gender, country, nationality, language, dob, phone) VALUES('$username','$password','$name','$email','$gender',$country,$nationality,$language,'$dob','$phone')"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); ...but I don't want to have to SET NAMES all the time. I made the following changes to /etc/my.cnf [client] default-character-set=utf8 [mysqld] init-connect=SET NAMES 'utf8' collation_server=utf8_unicode_ci character_set_server=utf8 default-character-set=utf8 I can see in phpMyAdmin that the changes have been made to the system variables, but still the only way it works is to send the SET NAMES 'utf8' query via PHP. What am I missing? Thanks, Rich

« previous php.i18n (#1071) next »