标题: 我的留言簿有点问题,请大家帮我解答下 [打印本页] 作者: 封xin封mg 时间: 2010-1-7 01:12 标题: 我的留言簿有点问题,请大家帮我解答下 <!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" />
<title>无标题文档</title>
</head>
<body>
<%
mydsn="dsn=information"
set conn=server.createobject("adodb.connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=D:\网站学习\database\information.mdb"
conn.Open Strconn
if request.form("task")="insert" then (为什么要这一句话)
if request.form("name")="" then
name="匿名"
else
name=request.form("name")
end if
if request.form("email")="" then
email="无"
else
email=request.form("email")
end if
if request.form("url")="" then
url="无"
else
url=request.form("url")
end if
sj=date()
sj=sj & " " & hour(time()) & ":" & minute(time())
if request("ly")="" then
response.write("请输入留言!!")
response.end
else
ly=request.form("ly")
end if
sql="insert into lyb(ip,name,url,email,sj,ly)values('"
sql=sql & request.servervariables(remote_addr) & "," & name & "," & url & "," & email & "," & sj & "," & ly & "')" (出错地方)
conn.execute(sql)
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from guestbook order by sj desc",mydsn,3,1
rs.pagesize=3
rs.absolutepage=1
if request("page")<>"" then rs.absolutepage=request("page")
rowcount=rs.pagesize
%>
<br />
<form method="post" action="<%=request.servervariables("script_name")%>"><br />
<input type="hidden" name="task" value="insert" /><br /> (有什么用啊)
姓名:<input type="text" size="20" name="name" /><br />
email:<input type="text" size="20" name="email" /><br />
主页:<input type="text" size="20" name="url" /><br />
留言:<br />
<textarea rows="5" cols="60" name="ly">
</textarea><br />
<input type="submit" value="记入留言簿" name="b1" />
<input type="reset" value="重写" name="b2" />
</form>
<hr />
<%
if not rs.eof then 如果我的数据库中没东西,这里会出错,应该怎么改?
do while not rs.eof and rowcount>0
%>
日期:<%=rs("sj")%><br />
姓名:<%=rs("name")%><br />
主页:<%=rs("url")%><br />
email:<%=rs("email")%><br />
留言:<br />
<%=rs("ly")%><br />
<hr />
<%
rowcount=rowcount-1
rs.movenext
loop
else
response.write("无")
end if
%>
<br />
<%
if rs.pagecount>1 then
%>
<table border="0">
<tr>
<td>留言分页</td>
<%
for i=1 to rs.pagecount
%>
<td>
<a href="<%=request.servervariables("script_name")%>?page=<%=i%>"><%=i%></a>
</td>
<%next%>
</tr>
</table>
<%
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>作者: 没心没肺 时间: 2010-1-7 01:12
<!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" />
<title>无标题文档</title>
</head>
<body>
<%
mydsn="dsn=information"
set conn=server.createobject("adodb.connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=D:\网站学习\database\information.mdb"
conn.Open Strconn
if request.form("task")="insert" then (为什么要这一句话)
if request.form("name")="" then
name="匿名"
else
name=request.form("name")
end if
if request.form("email")="" then
email="无"
else
email=request.form("email")
end if
if request.form("url")="" then
url="无"
else
url=request.form("url")
end if
sj=date()
sj=sj & " " & hour(time()) & ":" & minute(time())
if request("ly")="" then
response.write("请输入留言!!")
response.end
else
ly=request.form("ly")
end if
sql="insert into lyb(ip,name,url,email,sj,ly)values('"
sql=sql & request.servervariables(remote_addr) & "," & name & "," & url & "," & email & "," & sj & "," & ly & "')" (出错地方)
conn.execute(sql) [Microsoft][ODBC Microsoft Access Driver] 查询值的数目与目标字段中的数目不同。这是什么错啊?
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from guestbook order by sj desc",mydsn,3,1
rs.pagesize=3
rs.absolutepage=1
if request("page")<>"" then rs.absolutepage=request("page")
rowcount=rs.pagesize
%>
<br />
<form method="post" action="<%=request.servervariables("script_name")%>"><br />
<input type="hidden" name="task" value="insert" /><br /> (有什么用啊)
姓名:<input type="text" size="20" name="name" /><br />
email:<input type="text" size="20" name="email" /><br />
主页:<input type="text" size="20" name="url" /><br />
留言:<br />
<textarea rows="5" cols="60" name="ly">
</textarea><br />
<input type="submit" value="记入留言簿" name="b1" />
<input type="reset" value="重写" name="b2" />
</form>
<hr />
<%
if not rs.eof then 如果我的数据库中没东西,这里会出错,应该怎么改?
do while not rs.eof and rowcount>0
%>
日期:<%=rs("sj")%><br />
姓名:<%=rs("name")%><br />
主页:<%=rs("url")%><br />
email:<%=rs("email")%><br />
留言:<br />
<%=rs("ly")%><br />
<hr />
<%
rowcount=rowcount-1
rs.movenext
loop
else
response.write("无")
end if
%>
<br />
<%
if rs.pagecount>1 then
%>
<table border="0">
<tr>
<td>留言分页</td>
<%
for i=1 to rs.pagecount
%>
<td>
<a href="<%=request.servervariables("script_name")%>?page=<%=i%>"><%=i%></a>
</td>
<%next%>
</tr>
</table>
<%
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>作者: .嵿峜繌嗲﹖ 时间: 2010-1-7 01:12
以下是引用zh286091487在2007-3-24 15:32:30的发言:
<!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" />
<title>无标题文档</title>
</head>
<body>
<%
mydsn="dsn=information"
set conn=server.createobject("adodb.connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=D:\网站学习\database\information.mdb"
conn.Open Strconn
if request.form("task")="insert" then (为什么要这一句话)
if request.form("name")="" then
name="匿名"
else
name=request.form("name")
end if
if request.form("email")="" then
email="无"
else
email=request.form("email")
end if
if request.form("url")="" then
url="无"
else
url=request.form("url")
end if
sj=date()
sj=sj & " " & hour(time()) & ":" & minute(time())
if request("ly")="" then
response.write("请输入留言!!")
response.end
else
ly=request.form("ly")
end if
sql="insert into lyb(ip,name,url,email,sj,ly)values('"
sql=sql & request.servervariables(remote_addr) & "," & name & "," & url & "," & email & "," & sj & "," & ly & "')" (出错地方)
conn.execute(sql) [Microsoft][ODBC Microsoft Access Driver] 查询值的数目与目标字段中的数目不同。这是什么错啊?
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from guestbook order by sj desc",mydsn,3,1
rs.pagesize=3
rs.absolutepage=1
if request("page")<>"" then rs.absolutepage=request("page")
rowcount=rs.pagesize
%>
<br />
<form method="post" action="<%=request.servervariables("script_name")%>"><br />
<input type="hidden" name="task" value="insert" /><br /> (有什么用啊)
姓名:<input type="text" size="20" name="name" /><br />
email:<input type="text" size="20" name="email" /><br />
主页:<input type="text" size="20" name="url" /><br />
留言:<br />
<textarea rows="5" cols="60" name="ly">
</textarea><br />
<input type="submit" value="记入留言簿" name="b1" />
<input type="reset" value="重写" name="b2" />
</form>
<hr />
<%
if not rs.eof then 如果我的数据库中没东西,这里会出错,应该怎么改?
do while not rs.eof and rowcount>0
%>
日期:<%=rs("sj")%><br />
姓名:<%=rs("name")%><br />
主页:<%=rs("url")%><br />
email:<%=rs("email")%><br />
留言:<br />
<%=rs("ly")%><br />
<hr />
<%
rowcount=rowcount-1
rs.movenext
loop
else
response.write("无")
end if
%>
<br />
<%
if rs.pagecount>1 then
%>
<table border="0">
<tr>
<td>留言分页</td>
<%
for i=1 to rs.pagecount
%>
<td>
<a href="<%=request.servervariables("script_name")%>?page=<%=i%>"><%=i%></a>
</td>
<%next%>
</tr>
</table>
<%
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>作者: 新时代 时间: 2010-1-7 01:12
以下是引用zh286091487在2007-3-24 14:52:01的发言:
<!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" />
<title>无标题文档</title>
</head>
<body>
<%
mydsn="dsn=information"
set conn=server.createobject("adodb.connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=D:\网站学习\database\information.mdb"
conn.Open Strconn
if request.form("task")="insert" then (为什么要这一句话)这句话是对你表单的判断,当你的表单元素是"insert"的时候就执行插入操作。
if request.form("name")="" then
name="匿名"
else
name=request.form("name")
end if
if request.form("email")="" then
email="无"
else
email=request.form("email")
end if
if request.form("url")="" then
url="无"
else
url=request.form("url")
end if
sj=date()
sj=sj & " " & hour(time()) & ":" & minute(time())
if request("ly")="" then
response.write("请输入留言!!")
response.end
else
ly=request.form("ly")
end if
sql="insert into lyb(ip,name,url,email,sj,ly)values('"
sql=sql & request.servervariables(remote_addr) & "," & name & "," & url & "," & email & "," & sj & "," & ly & "')" (出错地方)
这个地方出错,也不知道你是什么错误,看看你的数据类型先!
conn.execute(sql)
end if
set rs=server.createobject("adodb.recordset")
rs.open "select * from guestbook order by sj desc",mydsn,3,1
rs.pagesize=3
rs.absolutepage=1
if request("page")<>"" then rs.absolutepage=request("page")
rowcount=rs.pagesize
%>
<br />
<form method="post" action="<%=request.servervariables("script_name")%>"><br />
<input type="hidden" name="task" value="insert" /><br /> (有什么用啊)