I have problems using utf8 in MySQL. I have the following table:
CREATE TABLE IF NOT EXISTS `notas` (
`id_nota` int(11) NOT NULL AUTO_INCREMENT,
`nombre_nota` varchar(25) NOT NULL,
`email_usuario` varchar(100) NOT NULL,
`descripcion` text NOT NULL,
`nota_creada_en` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`nota_modificada_en` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`borrado` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id_nota`,`email_usuario`),
KEY `notas_ibfk_1` (`email_usuario`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=6 ;
An the following record stored in the table:
(1, 'Nota1 de esta sólido', 'ricardo@gmail.com', 'Esta es una descripción 1', '2014-05-13 13:07:27', '2014-05-13 13:24:31', 0),
I'm working on PHPMyAdmin and the record above is how is displayed, I mean the text with quotes like "sólido"
is displaying fine.
But, finally when I request a query from PHP using PDO:
$con = new PDO('mysql:host='.DB_HOST.';dbname='.DB_DATABASE.';charset=utf8mb4', DB_USER, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4", PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET utf8mb4"));
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
The query returns the record but the contents without quotes, this is what I receive in PHP:
s\u00f3lido
instead of sólido
In the past, I've tried utf8 instead of utf8mb4 (according to this post) but I always get the same results.
I've tried many ways to solve it but the problem persists.
And finally: SHOW VARIABLES LIKE 'c%'
Variable_name Value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8mb4
character_set_system utf8
character_sets_dir /Applications/XAMPP/xamppfiles/share/charsets/
collation_connection utf8mb4_general_ci
collation_database utf8mb4_general_ci
collation_server utf8mb4_general_ci
completion_type NO_CHAIN
concurrent_insert AUTO
connect_timeout 10
I really appreciate any kind of help.