0
To a 1 behind I made a bank with colação latin1_swedish_ci and charset latin1,
html has become charset UTF-8
in the index that globes all pages inside html,
And php became UTF-8 with the codes per page:
ini_set('default_charset','UTF-8');
And in 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');
}
?>
All on the localhost working right,
When I exported the bank to Kinghost
Everything working right too,
Today, after 1 year, I import the database to the notebook and the open page on the localhost, is receiving the database data and displaying disfigured.
But what you get from the bank, it’s disfigured, it’s coming from what’s actually in the bank
At the bank, he’s disfigured too,
If I send my name "André" through the page, you’re saving "André"
But the previous records, imported, are incorrect, the name:
Letã-cia Martins
It’s in the bank this way, and when I get on my localhost page, it’s getting:
Letã-cia Martins
From what I’ve seen, back at the host, you’re saving wrong,
When sending the received UTF-8 word in html/php, it sends in UTF-8, until the save page has the code:
ini_set('default_charset','UTF-8');
Arrives at the bank and gets wrong, he recognizes the latin1,
If the bank is latin1, and I open here in localhost my name "André"
All right,
But it opens wrong, displays wrong, it tries to display in UTF-8,
I don’t understand why it used to work on the localhost, and now, after formatting and long, no,
And I also don’t understand why the same bank, and the same hosting files, are on my pc, and there it works, and here it doesn’t.
Is some setting ?
Some code that doesn’t work here on localhost and is working there ?
EDITED
Resolução Temporária:
Guys, I’ve been assigned a code like this: echo utf8_decode($variavel_do_banco); in the data coming from the bank, and gave Okay, it turns out that now 90% is solved, I wanted a code like the one above the final lines of the connected self.php it was to convert everything automatically into print, and it’s not working, there’s some that do it to replace and run without using Code on each echo ?
I tried the code down and it didn’t 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 in:
http://kunststube.net/frontback/
http://www.webdeveloper.com/forum/showthread.php?287107-Encoding-while-inserting-in-mysql
http://www.w3schools.com/php/php_ref_mysqli.asp
https://stackoverflow.com/questions/10829816/php-set-character-names-using-mysqli
header ("Content-Type: text/html; charset=utf-8");
– Edilson
That already has, is not the problem.
– Barack
ini_set
sets the encoding for character conversion functions - htmlentities, htmlspecialchars, etc. You can tryprint ini_get('default_charset');
, see this– Edilson