Collation problem in BD and PHP

0

When I execute the UPDATE statement in PHP, in order to save the changes in the database (PHPMyAdmin), the information is stored with rare characters, that is, the letter ñ or the accents are not recognized ....

The ñ appears like this: years The accents appear like this: region:

I must add some sentence and / or prefix when writing UPDATE SET_name SET ... Why does that happen? In my connection to BD, I have this:

$conexion = new PDO('mysql:host=localhost;dbname='.$bd_config['basedatos'], $bd_config['usuario'], $bd_config['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES  \'UTF8\''));

And even then, it is respected ......

It is worth mentioning that the collation, both for my tables and for the database in general, is UTF8_UNICODE_CI

    
asked by Cesar Esparza Vera 20.10.2016 в 09:46
source

1 answer

0

You have to ensure the coding of the client side and PHP I use the following code

header("Content-Type: text/html; charset=UTF-8");
if (function_exists("iconv") && PHP_VERSION_ID < 50600)
    {
    iconv_set_encoding("internal_encoding", "UTF-8");
    iconv_set_encoding("input_encoding", "UTF-8");
    iconv_set_encoding("output_encoding", "UTF-8");
    }
elseif (PHP_VERSION_ID >= 50600)
    {
    ini_set("default_charset", "UTF-8");
    }
    
answered by 20.10.2016 / 12:28
source