![]() |
Query returns results using bad encoding - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Query returns results using bad encoding (/showthread.php?tid=19620) |
Query returns results using bad encoding - El Forum - 06-12-2009 [eluser]jstuardo[/eluser] Hello... I have an encoding problem now. Well, I have spanish characters stored in a database. When I retrieve data, they are shown in an encoding similar to UTF-8. I write "similar" because when I use UTF-8 encoding in the HTML page, the characters aren't shown correctly. I have this configuration now: Code: $config['charset'] = "ISO-8859-1"; and this is inside the HEAD tag of the page: Code: $meta = array( Well, I am executing this query: Code: $sql = 'select lp.id, The nombre_comuna field contains the string "Ñuñoa" and it was correctly stored because I use MySQL Query Browser to see the data. But when I return the data using: Code: $query = $this->db->query($sql, array('id' => $id)); The following string is shown in the page: Ñuñoa Any help will be greatly appreciated Thanks Jaime Query returns results using bad encoding - El Forum - 06-12-2009 [eluser]slowgary[/eluser] Have you tried setting $config['charset'] to 'UTF-8'? Code: $config['charset'] = 'UTF-8'; Query returns results using bad encoding - El Forum - 06-13-2009 [eluser]jstuardo[/eluser] That was the default. I changed it to ISO-8859-1. Query returns results using bad encoding - El Forum - 06-13-2009 [eluser]jstuardo[/eluser] Never mind. The problem was in database.php configuration file. I changed the default value to: Code: $db['default']['char_set'] = "latin1"; and it worked. Jaime |