[eluser]Kopel[/eluser]
Hi,
I'm developing a multilang website on Codeigniter 1.6.1.
A part of the website is in French, so i have to deal with accents and special characters...
Everything is running fine on my local server.
But online, accents and special characters coming from database results are replaced with strange things like è, é, ê, etc...
So i've created a clean script with a select query without using the codeigniter db driver:
Code:
<?php
$db = mysql_connect('xxx', 'xxx', 'xxx');
mysql_select_db('xxx',$db);
$sql = 'SELECT * FROM news';
$req = mysql_query($sql) or die('');
while($data = mysql_fetch_assoc($req)) {
print_r($data);
}
mysql_close();
?>
This script returns the text with accents and special caracters not altered.
So, the problem is coming from the codeigniter db driver.
Here is the (ugly) solution that i found.
On the
system\database\drivers\mysql\mysql_driver.php file, i've changed:
Code:
function db_set_charset($charset, $collation)
{
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
}
To:
Code:
function db_set_charset($charset, $collation)
{
return True;
}
As you can see this is a pretty bad solution.
At least i can move on with my project...
But i definitely do not want to let this ugly fix into the final code!
I don't understand where the problem is coming from.
Do you have any clue?
Please help me to find the real origin of the problem.
Here is how codeigniter is setup:
My html header have:
Code:
<meta http-equiv="content-type" content="text/HTML; charset=utf-8" />
Into my
config.php:
Code:
$config['charset'] = "UTF-8";
Into my
database.php:
Code:
$db['production']['char_set'] = "utf8";
$db['production']['dbcollat'] = "utf8_general_ci";
And all my Mysql tables are set to: collation
utf8_general_ci
Let me know if you have any idea or if need more information.
Thanks!
Kopel