asp 读取php设置字符集问题
作者:admin 日期:2008-11-05
1.mysql中my.ini
[mysql]
default-character-set=utf8
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8
2.mysql-front中
设置建表urf8
3.asp 前台页中用gb2312显示,用ansi存
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<%
dim driverName,chs
driverName="Driver={mysql odbc 3.51 driver};server=localhost;database=people;uid=root;pwd=;"
set conn=server.createobject("adodb.connection")
conn.open driverName
'查询之前先执行下面这一句
set chs=conn.Execute("SET NAMES 'gb2312'")
'查询数据库表
sql = "Select * FROM lx"
Set rs = conn.Execute(sql)
if not rs.bof then
%>
<table>
<tr>
<td><b>序列号</b></td>
<td><b>标题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
conn.close
set adodataconn = nothing
set rs = nothing
%>
[mysql]
default-character-set=utf8
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=utf8
2.mysql-front中
设置建表urf8
3.asp 前台页中用gb2312显示,用ansi存
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<%
dim driverName,chs
driverName="Driver={mysql odbc 3.51 driver};server=localhost;database=people;uid=root;pwd=;"
set conn=server.createobject("adodb.connection")
conn.open driverName
'查询之前先执行下面这一句
set chs=conn.Execute("SET NAMES 'gb2312'")
'查询数据库表
sql = "Select * FROM lx"
Set rs = conn.Execute(sql)
if not rs.bof then
%>
<table>
<tr>
<td><b>序列号</b></td>
<td><b>标题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("title")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无数据.")
end if
rs.close
conn.close
set adodataconn = nothing
set rs = nothing
%>
评论: 0 | 引用: 0 | 查看次数: 2025
发表评论
你没有权限发表留言!