Hi!
I've the same problem with accents. Is there a solution yet?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi!
I've the same problem with accents. Is there a solution yet?
Ok, reply to myself.
I've found a weird solution.
I'm using EMS MYSQL Manager to manage my silverstripe db. When I export the database, it opens "sql monitor" with all the sql code and creates a .sql file too. In that file the charset isn't correct.
So, when I import the db in another host, I copy the text on the sql monitor (in the program I use) instead that .sql file.
I'm not sure if I explained it correctly, my english isn't really good :)
Hi @all,
I had the same problem...
Some MySQL-servers created a ISO connection by default.
So, you must call
mysql_query("SET NAMES 'utf8'");
directly after the connection to the db.
=> A parameter for enforcing a utf8-connection would be pretty useful.
Cheers,
Malte
Just for reference, here's the ticket relating to the issue, with an explanation from Sam, the project lead: http://open.silverstripe.com/ticket/2377. Unfortunately we can't simply switch connections by default without effect on legacy data, although I agree that it would be a nice optional setting for new sites in the meantime.
Hi,
a usual source of utf-8 problems with mysql is the mysql connection (mysql needs to be set to utf-8 on a per connection basis).
2 solutions:
Add these lines to your [mysqld] - section of my.cnf:
default-character-set = utf8
default-collation = utf8_general_ci
init_connect='SET NAMES utf8'
or run the following sql commands directly after connecting to the database:
mysql_query( 'SET NAMES utf8', $db_ss );
mysql_query( 'SET CHARACTER SET utf8', $db_ss );
mysql_query( "SET COLLATION_CONNECTION='utf8_general_ci'", $db_ss );
Just a simple and clean solution:
<br >
<br >Create a class:
<br >class UTF8MySQLDatabase extends MySQLDatabase {
<br >
<br > public function __construct($parameters) {
<br > parent::__construct($parameters);
<br > $this->query("SET CHARACTER SET 'utf8'");
<br > $this->query("SET NAMES 'utf8'");
<br > }
<br >}
<br >Add something like that to your "mysite/_config.php":
<br >global $databaseConfig;
<br >$databaseConfig = array(
<br > "type" => "UTF8MySQLDatabase",
<br >);
<br >
<br >Cheers,
<br >Malte
I think you mean;
class UTF8MySQLDatabase extends MySQLDatabase {
public function __construct($parameters) {
parent::__construct($parameters);
$this->query("SET CHARACTER SET 'utf8'");
$this->query("SET NAMES 'utf8'");
}
}
global $databaseConfig;
$databaseConfig = array("type" => "UTF8MySQLDatabase");
I have excatly the same problem!
I did try the following steps:
1) I changed the my.cnf file, like described by Radon.
2) It did place a file 'UTF8MySQLDatabase.php' in the code directoty of mysite and did change the connection type to "UTF8MySQLDatabase" like described by mattclegg.
Unfortunately nothing of this did help :(
Here the the original website (old server): http://www.infokomm.de
And here is the migrated website (new server): http://54.246.96.76/
What's wrong?
I have no idea :(