CodeIgniter Forums
Help with MySQL character sets and collations - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Help with MySQL character sets and collations (/thread-13213.html)



Help with MySQL character sets and collations - El Forum - 11-14-2008

[eluser]Daniel Peraza[/eluser]
Hi!, I'm using the Active Record Class to store user-edited data into a MySQL 5 DB, which uses utf8_general_ci as collation. The problem is that A.R.C. is not sanitizing the data properly and when I try to use spanish characters such as áéíóúñ, the data is stored in the DB as áéí&At;.

My database.php config file has these settings:

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";



Help with MySQL character sets and collations - El Forum - 02-10-2009

[eluser]Jiacomo[/eluser]
I have the same problem!

[quote author="Daniel Peraza" date="1226717970"]Hi!, I'm using the Active Record Class to store user-edited data into a MySQL 5 DB, which uses utf8_general_ci as collation. The problem is that A.R.C. is not sanitizing the data properly and when I try to use spanish characters such as áéíóúñ, the data is stored in the DB as áéí&At;.

My database.php config file has these settings:

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
[/quote]


Help with MySQL character sets and collations - El Forum - 02-10-2009

[eluser]bitist[/eluser]
Check if your database tables collation is utf8_general_ci.
You can check this with PHPMyAdmin Collation row.


Help with MySQL character sets and collations - El Forum - 02-10-2009

[eluser]Jiacomo[/eluser]
Hi, thanks for the reply.
My tables collation is "utf8_unicode_ci", so I set:

$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_unicode_ci";

...


Help with MySQL character sets and collations - El Forum - 02-10-2009

[eluser]bitist[/eluser]
I don't know the difference between the 2 collation, but I used utf8_general_ci, so you should try to convert one of you table to utf8_general_ci and maybe that'll work for you.


Help with MySQL character sets and collations - El Forum - 02-11-2009

[eluser]Daniel Peraza[/eluser]
Well, in my case I had it done previously. But my problem was that I was starting to learn CI and I wasn't sure that Active Record Queries would escape values properly before executing its statements. So I had left some code somewhere to automatically escape string values by calling
Code:
htmlentities()
, and of course, the result was the substitution of all accented vowels by its corresponding html entities. I had forgotten this piece of code but when I realized of it, I remove it and all worked wonderful.


Help with MySQL character sets and collations - El Forum - 02-11-2009

[eluser]Skuja[/eluser]
In what encoding your controller/view files ar encoded in ?