Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why database result doesn't show accents?

I'm migrating a project from a CMS called "Freekore" to CodeIgniter, with my old CMS I didn't have this problem but with CI I can't figure out why I have problems with special characters as ñ,á,é,í etc. I think I've tried everything.
I got this in header

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

also added this

<?php header('Content-Type: text/html; charset=UTF-8'); ?>

on database config

$db['local']['char_set'] = 'utf8';
$db['local']['dbcollat'] = 'utf8_general_ci';

and on config file

$config['charset'] = 'UTF-8';

But I still get this

COMUNICACIÓN Y PRODUCCIÓN EDITORIAL

instead of this

COMUNICACIÓN Y PRODUCCIÓN EDITORIAL

ah and also added this to .htaccess

AddDefaultCharset UTF-8

Edit
Using this I found out that Current character set is latin1 but how? I've checked database and tables and are utf8_general_ci

Edit 2
I did a new database and checked every column collation, now I'm using utf8_unicode_ci on the database, on every table and on ever row, but I still have the same problem Current character set is latin1

Edit 3
I decided to use utf8_decode and seemed to work but I still have problems with uppercases

like image 607
laviku Avatar asked Mar 12 '26 17:03

laviku


1 Answers

After hours searching for something that help me resolve the problem I found an answer so easy in this post so before execute the insertion I used this mysql_query("SET NAMES utf8"); and now the characters are shown as they should. Thank you so much for your help.

like image 164
laviku Avatar answered Mar 15 '26 06:03

laviku