I have a PHP file which inserts $mail and $password in my database. See code below. My php file, my BD and my table fields are in utf-8. So what I do not understand is why the mail I send “Philémon” goes as “Philémon” in my table. By the way I know it is not a mail format. It is just for the sake of testing.
My PHP:
<?php
header('Content-Type: text/html; charset=utf-8');
require("php/connect.inc.php");
$mail = mysql_real_escape_string("Philémon");
$password = sha1("pass123");
mysql_query("INSERT INTO ENS_MEMBRES (ENS_MAIL, ENS_PASS) VALUES ('$mail','$password')");
?>
Your PHP source code is probably UTF-8 encoded; your database connection is probably ISO-8859-1 encoded, it’s the default connection encoding of mySQL. That will cause the UTF-8
éto be interpreted as two separate bytes, and stored that way in your mySQL table.Solution: do a
before sending the data; if that function isn’t available, use