0

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

Steve
  • 1,553
  • 2
  • 20
  • 29
user3536315
  • 17
  • 2
  • 7
  • 1
    possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – jeroen Apr 17 '14 at 14:30
  • I fail to see how your two code blocks are connected. You don't actually use mysql to retrieve anything in the first block and you don't assign anything into $_SESSION. And in the second block there's no mysql code at all. If the problem is the string gets corrupted in the session between the two scripts, then that's not mysql's fault. – Marc B Apr 17 '14 at 14:34
  • what are these " invalid UTF-8 character(s)" looks like? – Your Common Sense Apr 17 '14 at 14:40
  • It's just an "ã". And that frase is the only thing that appears on the whole page. (I'm using mpdf script, it might have to do with it). – user3536315 Apr 17 '14 at 14:42

1 Answers1

1

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');
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345