You need to find out what character set/encoding the database you have MODx installed in is using, and make sure the tables inside it have a collation that matches. If these are not utf8, then you cannot use utf8 or it will try converting everything from whatever encoding you have to UTF-8 automatically as part of the mysql client connection.
-
- 805 Posts
That’s the thing. They are set correctly. For the database I get...
show variables like "character_set_database";
character_set_database utf8
show variables like "collation_database";
collation_database utf8_unicode_ci
... and for the tables I get, for example (showing only encoding related info for brevity)
SHOW CREATE TABLE `so_site_content`;
CREATE TABLE `so_site_content` ... `type` varchar(20) collate utf8_unicode_ci ... `contentType` varchar(50) collate utf8_unicode_ci ... `pagetitle` varchar(255) collate utf8_unicode_ci ... `longtitle` varchar(255) collate utf8_unicode_ci ... `description` varchar(255) collate utf8_unicode_ci ... `alias` varchar(255) collate utf8_unicode_ci ... `link_attributes` varchar(255) collate utf8_unicode_ci ... `published` ... `introtext` text collate utf8_unicode_ci ... `content` mediumtext collate utf8_unicode_ci ... `menutitle` varchar(255) collate utf8_unicode_ci ... DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ...
Paul
-
- 805 Posts
I recently moved all my sites when I upgraded my server. In the process of doing this I had to export and re-import my modx databases. I encountered the same encoding problem, so I realised that this was not an upgrade issue. In fact, the problem was that I had been using phpmyadmin to do the export. I don’t know if I just didn’t choose the right options when doing the export, or if the version of phpmyadmin that I was using just has a buggy export facility, but it was breaking the encodings somehow.
I just used the standard mysqldump command and that fixed all problems. Conclusion: Don’t rely on phpmyadmin to correctly export utf-8 encoded websites.
Cheers,
Paul
-
- 206 Posts
Without exporting/importing the database I experienced that $database_connection_charset = ’utf8’; tries to read 8 bit characters. I suppose it also writes 8 bits.
For me it’s only working with $database_connection_charset = ’’; -- so if it does, I think it’s a bad habit to change this setting during the upgrade process.
(My database collations in different installs are either utf8_general_ci and utf8_unicode_ci.)
I’ve read this before about phpMyAdmin’s export function.
-
- 55 Posts
I have had the same encoding problem.
Testing a website locally, with UTF-8 set. Then moved the website to 0.9.6.2 and it all went astray.
I had two backups : one made with PHPMyAdmin, and the other by MODx. None of them two worked.
I have removed UTF-8 from $database_connection_charset and it now works.
What I did was a fresh install of MODx instead of an upgrade and the $database_connection_charset parameter was set to UTF-8. In the original config.inc.php, it was set to ’’.
My two backup files were made with settings : $database_connection_charset=’’
It is thus important to pay attention to this parameter when upgrading or moving from a server to another.
Hmmm ... could this be another manager login page warning flag/check?
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me