Home > Backend Development > PHP Tutorial > php写下mysql中文乱码啊已经是utf8了

php写下mysql中文乱码啊已经是utf8了

WBOY
Release: 2016-06-13 12:16:50
Original
829 people have browsed it

php写入mysql中文乱码啊,已经是utf8了

本帖最后由 itljl 于 2015-03-20 10:59:23 编辑 php文件已经是UFT8统码,


<br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><br /><br />$conn = mysql_connect("localhost","test","test");<br />if (!$conn)<br />  {<br />  die('Could not connect: ' . mysql_error());<br />  }<br />//mysql_query("set test 'utf8'");<br />mysql_set_charset("utf8" , $conn); <br />//选择数据库<br />mysql_select_db("test", $conn);<br /><br />//往表里插数据<br />mysql_query("INSERT INTO test (id, myusername) <br />VALUES (2,'中文2')");<br /><br />//mysql_query("INSERT INTO user (id, myusername) <br />//VALUES (". intval($str_id) . "," . $str_name . ")");<br /><br />//关闭数据库连接<br />mysql_close($conn);<br />
Copy after login


phpmysql 中数据库的配置。


请问各位大牛是为什么呢?

------解决思路----------------------
mysql_query("set names utf8");
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template