3
None of the solutions suggested in various forums, websites and the like worked. I performed several tests and none of them worked and so I came here.
The website where the error occurs is this: http://simuladoconcursosbrasil.com.br/
It was not developed by me, a client of mine requested that I fix this problem for him.
All special characters are always replaced by à . I tried to change the encoding to ISO
and the error remained, I tried to change the coding in the database, force UTF-8
in the header
, put the javascript
to interpret as UTF-8
and none of it worked.
The connection in the database is as follows:
<?php
$bd_host = "localhost";
$bd_user = "simulado_bd"; // Usuário do Banco de Dados
$bd_pass = "********"; // Senha do Bando de Dados
$bd_bd = "simulado_bd"; // Nome do Banco de Dados
$conectar = mysql_connect($bd_host, $bd_user, $bd_pass) or die (mysql_error());
mysql_select_db($bd_bd, $conectar);
mysql_query('SET CHARACTER SET utf8');
What was suggested? what is the file Find? of the base?
– rray
Have you tried using the HTML5 <meta charset="UTF-8"> tag? It doesn’t cost to try :)
– mauricio caserta
How is your connection class to the database?
– Gabriel Rodrigues
related answered questions: Accentuation is unreadable on the page and Write MYSQL data in en / UTF8 format
– Pedro Sanção
recommended reading: Why should we not use mysql type functions_*?
– Pedro Sanção
UTF-8 encoding files, no BOM, UTF-8 general ci database
– Raphael Cordeiro
Sanction, as I mentioned above, was not programmed by me, I have not used mysql_ functions for a long time.
– Raphael Cordeiro
So far none of the tips solved. The data in the database are in UTF-8, but are not read as they should.
– Raphael Cordeiro
@Raphaelcordeiro, try adding the charset to the HTTP header with
header('Content-Type: text/html; charset=utf-8');
– Pedro Sanção
@Sanction I tried to use your suggestion and the error remained.
– Raphael Cordeiro
Looking at the source of the page, it seems to me that several attempts have been made to tidy up the data, including "search and replace" manually. It is probably the case to review the database directly, and then fix PHP. It seems to me to have entities mixed with wrong characters, and even double Encounter.
– Bacco
Raphael, if it is related only to contents coming from the base, you need to see how it was recorded at the base, is that it is not worth doing an inclusion test of any accented text and then read it using utf8_encode / utf8_decode?
– Thyago ThySofT
And how would I do that, @Thyagothysoft ? Bacco, I tried to make a substitution to fix yes, using the codes referring to accented characters, but it didn’t work, as you can notice.
– Raphael Cordeiro
@Raphaelcordeiro the first thing would be to tidy up the database then, even manually. If you keep trying to tidy up by PHP, you may have apparently solved it, but you end up creating or hiding a bigger problem. Once you are sure that DB is correct, you can try to solve PHP. PS: Remember first of all, restore the DB backup from before attempts, so as not to complicate too much.
– Bacco
One thing seems certain, are two encoding errors, the menu presents a type of error of symbols characters, already the questions and answers that I believe are DB seems to be another encoding error.
– Thyago ThySofT
The ones I need to solve are just the ones pulled from the database, the other coding problem I can solve. I will restore the backup of the script database, the way it came (and worked on another server).
– Raphael Cordeiro
If you can make a test.... In the inclusion form for the BD, send the fields like this:
htmlspecialchars($_POST['blablabla'], NULL, 'UTF-8')
can you see how you are? At least you will be sure of a new content included in utf-8.– Thyago ThySofT
Read the dice coming from the comic so:
utf8_encode($resultado)
these tests are for tracking, we will find the problem xD– Thyago ThySofT