再次遭遇PHP对MYSQL插入中文和显示时出现乱码
之前搞定了这些程序,今天删除数据库后再整理一下程序,对数据库插入中文,又开始出现乱码了。
1,我的
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->$sqlb = "create table test
(
.....
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;";
[b]3,连接数据库时,定义编码:[/b]
[code=PHP]
$conn=mysql_connect($host,$user,$pwd);
mysql_query("SET
character_set_connection=utf-8,
character_set_results=utf-8,
character_set_client=binary",$conn);
$conn=mysql_connect($host,$user,$pwd);
mysql_query("SET
character_set_connection=utf-8,//这里的utf-8改写成utf8
character_set_results=utf-8,//同上
character_set_client=binary",$conn);
<br><font color="#e78608">------解决方案--------------------</font><br>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号