简体   繁体   中英

Error on Mysql utf8 characters

I am having an error with some Mysql Characters.

<?php


$con = mysql_connect("localhost", "root", "");

if(!$con){

die(mysql_error());
echo "Não foi possivel ligar-se à base de dados";

}


$select_db = mysql_select_db("desempenho", $con);

if(!$select_db){

die(mysql_error());
echo "Não foi possivel selecionar a base de dados";

}

mysql_query("SET NAMES 'utf8'");

?>

And now here is another page where this is included:

include "../includes/connect.php";

session_start();

$nome = $_SESSION['nome'];

and it goes on.

The $nome variable is passed throught session and gotten from the login. I get an error printing this variable when it has a name like "João" because of the "ã". (this variable stores the username gotten on the login)

I also have the html tag to recognize UTF-8 Characters

<meta http-equiv='Content-type' value='text/html; charset=UTF-8' />

this is the error: HTML contains invalid UTF-8 character(s)

Thanks in advance

I also have the html tag to recognize UTF-8 Caracters

this HTML tag is totally useless . It's HTTP Header sets encoding, not HTML tag.

header('Content-Type: text/html; charset=utf-8');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM