Welcome Guest, Not a member yet? Register   Sign In
Insert French Character to Table
#1

[eluser]Unknown[/eluser]
Hi,

I have a simple table, it uses "latin1_swedish_ci" collation.
When i insert it from a simple PHP script without Code Igniter to the same table, the french characters are inserted 100% correctly.

But when i execute the query from Code Igniter to the same table, french chars are replaced with question mark.

Here is my CI code.
Code:
$str = mt_rand(1, 100000).' Digsby est un client multiprotocole de messagerie instantanée qui vous permet de parler avec tous vos amis sur AIM, MSN, Yahoo, ICQ, Google Talk et Jabber avec une liste de contacts simple à gérer.';

$this->db->simple_query("SET NAMES UTF8");

$q2 = "UPDATE `test` SET `something` = '$str' WHERE `the_id` = 2 LIMIT 1";
var_dump($q2);
$this->db->query($q2);

Even when i var_dump() the query, the query is normal (french chars are not replaced). But on phpmyadmin, it is not inserted correctly.

Here are the french characters

Digsby est un client multiprotocole de messagerie instantanée qui vous permet de parler avec tous vos amis sur AIM, MSN, Yahoo, ICQ, Google Talk et Jabber avec une liste de contacts simple à gérer.
#2

[eluser]tonanbarbarian[/eluser]
latin1_swedish_ci collation on the database would probably not support any accents or whatever is used in your french characters

best best is to convert the table, and all of the text fields in it, to utf8_general_ci, but be aware any existing records may not be updated
#3

[eluser]Unknown[/eluser]
[quote author="tonanbarbarian" date="1289302919"]latin1_swedish_ci collation on the database would probably not support any accents or whatever is used in your french characters

best best is to convert the table, and all of the text fields in it, to utf8_general_ci, but be aware any existing records may not be updated[/quote]
I have tried to utf8_general_ci but characters are truncated on special character.

For example :
should be : simplexà gérer
but on database : simplex

Plus on latin1_swedish_ci strangely my non-CI code can insert correctly, so probably i don't need to alter the table.
#4

[eluser]potatoDie[/eluser]
For me, changing the settings to utf8 of the database definition itself didn't work. But leaving the database collation at latin1_swedish_ci and using this also for the CI-settings (config/database.php) worked ok:

Code:
$db['default']['dbcollat'] = "latin1_swedish_ci";

I suppose any other latin would do, but not utf8?




Theme © iAndrew 2016 - Forum software by © MyBB