On a 1 atraz I made a bank with collation latin1_swedish_ci and charset latin1,
The html has been charset UTF-8
in the Index that emgloba all pages in html,
And php got UTF-8 with the codes per page:
ini_set('default_charset','UTF-8');
And in the connection.php is:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL ^ E_DEPRECATED);
setlocale(LC_ALL,"pt_BR");
ini_set('default_charset','UTF-8');
date_default_timezone_set('America/Sao_Paulo');
$db_servidor="localhost";
$db_usuario="XXXX";
$db_senha="XXXX";
$meubanquinho="XXXX";
$conexao = new mysqli($db_servidor, $db_usuario, $db_senha, $meubanquinho);
if (mysqli_connect_errno()) {trigger_error(mysqli_connect_error());
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
}
?>
Everything on the localhost running right,
When I exported the bank to Kinghost
Everything working right too,
Today, after 1 year, I import the bank to the notebook and the page opened on localhost, is receiving the data from the database and displaying unconfigured.
But what you get from the bank, it's unconfigured, what's really in the bank is coming
There on the bench, it's unconfigured too,
If I send my name "André" through the page, you are saving "André"
But the previous imported records are incorrect, the name:
Letícia Martins
You're on the bank this way, and when I get on my localhost page, you're getting:
Letícia Martins
From what I saw, there on the host, you're saving wrong,
When sending the UTF-8 word received in html / php, it sends UTF-8, so in the save page it has the following code:
ini_set('default_charset','UTF-8');
You get on the bank and it goes wrong, it recognizes the latin1,
If on the bank become latin1, and I open here at localhost my name "André"
Alright,
But it opens wrong, displays wrong, it tries to display in UTF-8,
I do not understand why it worked before in localhost, and now, after formatting and a lot of time, no,
And I do not understand why the same bank, and the same files of the hosting, are in my pc, and there it works, and not here.
Is it any configuration?
Some code that does not work here on localhost and is it working there?
EDITED
Resolução Temporária:
People, I was given a decode like this: echo utf8_decode ($ variable_of_bank); since it comes from the bank, and gave right, it happens that now 90% is solved, I wanted a type code that one from above the final lines of eu conexao.php it was to convert everything to automatic printing, and it is not working, does anyone have to do that to replace and run without using decode in every echo?
I tried the codes below and it did not work:
$charset = "utf8";
mysqli_set_charset ( $conexao , $charset );
$conexao->set_charset("utf8");
$conexao->query("SET character_set_connection = utf8");
$conexao->query("SET character_set_client = utf8");
$conexao->query("SET character_set_results = utf8");
$conexao->query("SET COLLATION_CONNECTION = 'utf8';");
$conexao->query("SET NAMES utf8");
I read about it on: