Daniel Asked: 2020-06-18 11:24:26 +0800 CST 2020-06-18 11:24:26 +0800 CST 2020-06-18 11:24:26 +0800 CST Problems with UTF-8 encoding in mysql 772 I have problems with the character encoding with the ñ and accents, the page is in utf-8 and the table and the DB in utf-8_general_ci but it happens as in the following image. Any solution? $connection = new mysqli($host,$dbuser,$dbkey,$database); php 2 Answers Voted Best Answer Diablo 2020-06-18T13:29:19+08:002020-06-18T13:29:19+08:00 I leave you a possible example: //Tu conexión $conexion = new mysqli($host,$usuariodb,$clavedb,$basededatos); //Comprobamos conexión. if ($conexion->connect_error) { die("La conexión fallo: " . $conexion->connect_error); } //Caracteres UTF-8. if (!$conexion->set_charset("utf8")) { printf("Error cargando el conjunto de caracteres utf8: %s\n", $conexion->error); exit(); } //Añades tu sentencia. Manual mysqli::set_charset Sal 2020-06-18T13:12:02+08:002020-06-18T13:12:02+08:00 After creating the connection and before doing the insert: $conexion->set_charset('utf8');
I leave you a possible example:
Manual mysqli::set_charset
After creating the connection and before doing the insert: