1

I use CodeIgniter and MySQL. I am getting the following message:

Can't initialize character set iso 8859-15 (path: /usr/share/mysql/charsets/)

I use a hosted server and have no access to the usr directory. This is the function in the CI mysql_driver class regarding charset:

function db_set_charset($charset, $collation) {
  if (!isset($this->use_set_names)) {
    // mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
    $this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
  }
  if ($this->use_set_names === TRUE) {
    return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
  } else {
    return @mysql_set_charset($charset, $this->conn_id);
  }
}

The CI Config has the UTF-8 setting:

$config['charset'] = 'utf-8';

My Notepad++ is set to UTF-8 respectively ANSI. How can I change the global MySQL setting to UTF-8? Do I have to add a config.php in my web server settings with MySQL character settings? Like character_set_database="utf-8".

Why does the notice with iso-8859 appear? For me, iso-8859 is good, because it can show German special chars, UTF cannot.

I have the solution: CI is set to the following in the conig.php $config['charset'] = 'utf-8';

When I use utf8_encode before print, I hardcode the char setting to UTF 8 and it works. If I do not use the function, it will show wrong characters. I do not understand why I have to use the function because the config setting has UTF-8. I tried to print $config['charset'] to verify, but no output.

Timo

Timo
  • 2,922
  • 3
  • 29
  • 28

0 Answers0