UTF8 only works in mysql or only on the page

Asked

Viewed 71 times

0

In Coon.php that serves as a connection to my database, if I add this code:

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');

the name is as in the image below:

inserir a descrição da imagem aqui

If I take it, it looks like this.. Using this in the database is "Braganã§Ã£o" instead of "Braganção" and the problem is, when I will carry more things via json/ajax etc... it will take "Braganã§Ã" and not "braganção"

inserir a descrição da imagem aqui

goal: make the name stay utf8 both on the page both in the database to always pull the correct name

  • On the page is the goal with utf-8

  • @rray yes both this <meta charset="utf-8"> both <meta http-equiv="content-type" content="text/html;charset=utf-8" />

  • Your file was saved as utf-without GOOD? Can guarantee the recorded data are with the right?

  • @rray utf-without?? , the structure in phpadmin is in utf8_general_ci

  • When I pull from the database it does that $sql = "ALTER DATABASE portfolio CHARSET = UTF8 COLLATE = utf8_general_ci";

  • php file, see in Notepad++ if it est[a as utf-8 without good

  • @rray as I see it explains me doing the favor ;)

  • Click on the enconding menu that already appears or at the bottom right corner

  • @rray is in UTF8 - (NO GOOD)

  • @rray in which Meeting I place?

  • That’s right.

  • @rray and now :( ???

  • Fractionates the project into parts to find the problem. Create a new file, clean and with correct charset, make the connection and have the data printed with echo. At the beginning of the php file set: header('Content-Type: text/html; charset=utf-8'); post the result.

  • 1

    Put the code snippet that shows the above characters, apparently you are doing double conversion.

  • 3

    This question Doubt with charset=iso-8859-1 and utf8 is different, but the answer there explains how to solve the problem step-by-step.

Show 10 more comments

1 answer

1


You can specify the document encoding right after starting the tag

 <?php
    header("Content-Type: text/html charset='utf-8'");
 ?>

And right after just include the structure you were already using

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');

  • put this on Coon.php?

  • even putting this, when I press the button press it will pull more things from the bank, appears Braganã§

Browser other questions tagged

You are not signed in. Login or sign up in order to post.