会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
LiveStar Study Log
博客园
首页
新随笔
管理
PHP返回mysql数据库中文字符出现乱码问题之解决方案
在查询前插入:
mysql_query("set names 'utf8'");
for example:
mysql_connect
(
"
localhost
"
,
"
root
"
,
"
123456
"
);
mysql_select_db
(
"
test
"
);
mysql_query
(
"
set names 'utf8'
"
);
$result
=
mysql_query
(
"
select * from info
"
);
echo
"
<table border=1>
"
;
echo
"
<tr><td>name</td><td>id</td><td>tel</td></tr>
"
;
while
(
$arr
=
mysql_fetch_array
(
$result
)) {
echo
"
<tr><td>
"
.
$arr
[
0
]
.
"
</td>
"
;
echo
"
<td>
"
.
$arr
[
1
]
.
"
</td>
"
;
echo
"
<td>
"
.
$arr
[
2
]
.
"
</td></tr>
"
;
}
echo
"
</table>
"
;
mysql_close
();
posted @
2008-07-25 13:52
LiveStar
阅读(
547
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告