我正在尝试将汉字存储在 mysql 数据库中,但它存储了一些杂乱的字符。请帮忙..这是我的代码-
<?php header("Content-Type: text/html; charset=UTF-8");
if(isset($_POST['submit']))
{
$conn=mysql_connect("localhost","root","") or die("CONNECTION FAILED");
$db=mysql_select_db("mytest",$conn) or die("DATABASE DOES NOT EXISTS");
mysql_query("SET character_set_client=utf8", $conn);
mysql_query("SET character_set_connection=utf8", $conn);
mysql_query("INSERT INTO tbl_test(id,name)
VALUES (null, '".$_POST['fname']."')") or die(mysql_error());
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="" method="post">
Name: <input type="text" name="fname" />
<input type="submit" name="submit" />
</form>
</body>
</html>