Quote from: Bogdan at Dec 04, 2008, 10:23 AM
Hi everyone!
Just a short update on this topic: I just downloaded latest SVN version and installed it on my server (PHP 5.1.2 / MySQL 5.0.26). Both the database and MODx are set to UTF-8. When I insert a russian Word like "Предлагаем" into a document and save it I get "??????????" when I reopen the same document in the manager.
I tried this in older MODx installations and it works perfectly in 0.9.5 and 0.9.6.1.
I don’t know what causes this problems in 0.9.6.2 and the RCs of 0.9.6.3 but I hope it can be fixed.
Thanks,
Bogdan
Hi Bogdan,
This is what I do always to avoid such issues with encoding:
1. open phpMyAdmin and find the database that will be used (left side, drop-down box). check the default encoding - on the right side (of course, you should select your database before in the drop-down box) click on the tab Operations and you will see there drop-down box named "Colllation". Usually it will be latin1_swedish_ci. Change if to utf8_general_ci and click on the button "Go"
2. find the file index.php in the folder "manager", open it and find the string @mysql_query("{$database_connection_method} {$database_connection_charset}");
it will be on 141 line or smth like that.
add before the next strings:
mysql_query("SET NAMES ’utf8’;",$modxDBConn);
mysql_query("SET CHARACTER SET ’utf8’;",$modxDBConn);
mysql_query("SET SESSION collation_connection = ’utf8_general_ci’;",$modxDBConn);
so you should see smth like:
mysql_select_db($dbase);
mysql_query("SET NAMES ’utf8’;",$modxDBConn);
mysql_query("SET CHARACTER SET ’utf8’;",$modxDBConn);
mysql_query("SET SESSION collation_connection = ’utf8_general_ci’;",$modxDBConn);
@mysql_query("{$database_connection_method} {$database_connection_charset}");
save this file.
3. find the file dbapi.mysql.class.inc.php in the folder "manager/includes/extenders/"
open it and find
@mysql_query("{$database_connection_method} {$charset}", $this->conn);
add before
mysql_query("SET NAMES ’utf8’;", $this->conn);
mysql_query("SET character_set_results = ’utf8’;", $this->conn);
mysql_query("SET collation_connection = ’utf8_general_ci’;", $this->conn);
so you will see
mysql_query("SET NAMES ’utf8’;", $this->conn);
mysql_query("SET character_set_results = ’utf8’;", $this->conn);
mysql_query("SET collation_connection = ’utf8_general_ci’;", $this->conn);
@mysql_query("{$database_connection_method} {$charset}", $this->conn);
save this file.
That’s all.
It will be better to do this actions before you install MODx.
If you have already installed MODx and insterted many text content then it might be difficult to fix it.