MySQL Chinese cannot read ...
This is how the MySQL database is encoded
This is the result of the background data, do not use Chinese words will normally write to the background, the use of Chinese words can not be written. (Watch the last few rows of data)
If you write to the database directly in Chinese, it will be displayed.
PHP Code section
if (Isset ($_post[' B1 '))
{
$username =$_post["username"];
$message =$_post["message"];
if ($username = = "")
{
echo "";
if ($message = = "")
{
echo "";
}
}
Else
{
$addtime =date ("y-m-d h:m:s");
$id =mysql_connect ("localhost", "root", "1234");
mysql_select_db ("Gbook", $id);
$query = "INSERT into message (author,addtime,content,reply) VALUES (' $username ', ' $addtime ', ' $message ', ') ';
$result =mysql_query ($query, $id);
Mysql_close ($id);
echo "result=". $result;
echo "";
}
}
------Solution--------------------
$username =iconv (' gb2312 ', ' utf-8 ', $_post["username"]);
$message =iconv (' gb2312 ', ' utf-8 ', $_post["message"]);
------Solution--------------------
Database encoding is UTF8
If you write to the database directly in Chinese, it will be displayed. (chasing after a line)
phpMyAdmin will do coding settings, naturally no problem
Your code is not coded, so it is normal for the problem to occur!
When the file encoding is GBK (ANSI under Windows) should be
mysql_query (' Set names GBK ');
When the file encoding is utf-8, it should be
mysql_query (' Set names UTF8 ');