Welcome Guest, Not a member yet? Register   Sign In
Help with MySQL character sets and collations
#1

[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";
#2

[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]
#3

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

[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";

...
#5

[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.
#6

[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.
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB