想做一个可以二级分类的书库,没有想到插不进数据
add.asp
<!--#include file="conn.asp"-->
<form action="allsave.asp" method="post" name="form1">
标题<input name="title" type="text" maxlength="5 "/><br>
类别
<%
set rs=server.createobject("adodb.recordset")
sql = "select * from bcn"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="bcn">
<option selected value="<%=trim(rs("bcn"))%>"><%=trim(rs("bcn"))%></option>
<%
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("bcn"))%>"><%=trim(rs("bcn"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="scn">
<option value="" selected>不指定小类</option>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from scn'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=trim(rs("scn"))%>"><%=trim(rs("scn"))%></option>
<%
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("scn")%>"><%=rs("scn")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<tr><br>
内容<textarea name="con" cols="70" rows="12"></textarea><br>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置">
</form>
我想add.asp应该是没错吧,为了安全起见还是贴出来吧
下面这个是保存的allsave.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
function checkStr(txtSql)
txtSql=Replace(txtSql, "'", "'")
txtSql=Replace(txtSql, "+", "+")
txtSql=Replace(txtSql, "<", "<")
txtSql=Replace(txtSql, ">", ">")
txtSql=Replace(txtSql, "(", "(")
txtSql=Replace(txtSql, ")", ")")
txtSql=Replace(txtSql, "$", "$")
txtSql=Replace(txtSql, "^", "︿")
txtSql=Replace(txtSql, "&", "&")
txtSql=Replace(txtSql, "*", "*")
txtSql=Replace(txtSql, "#", "#")
txtSql=Replace(txtSql, "?", "?")
txtSql=Replace(txtSql, "!", "!")
checkStr=txtSql
end function
dim title,con,bcn,scn,msg
msg=""
title=checkStr(trim(request.form("title")))
con=checkStr(trim(request.form("con")))
if trim(title)="" then msg="<li>标题不能为空"
if trim(con)="" then msg=msg&"<li>内容不能为空"
if len(title)>10 then msg="<li>标题限制在10字以内"
if len(con)>100 then msg=msg&"<li>内容限制在100字以内"
if msg="" Then
set rs= Server.CreateObject("adodb.recordset")
sql= "select * from guestbook"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("con")=con
rs("bcn")=bcn
rs("scn")=scn
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write("<A HREF=list.asp>返回</A>")
%>
<%
else
response.write"错误原因如下:"
response.write msg
response.write"<BR>"
response.write("请返回继续<A HREF=list.asp>填写</A>")
end if
%>
问题应该是出在这个文件吧
我是菜鸟还请大家帮忙点点错误
还有在大类我已经建了一个类别并且在add.asp中可以正常显示
[此贴子已经被作者于2006-2-3 0:47:30编辑过]