论坛: 网站建设 标题: 请指点一下,一段ASP代码,测试的时候总是出错。 复制本贴地址    
作者: lincoln [lincoln]    论坛用户   登录
代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="CONFIG.ASP" -->
<!--#include file="CONN.ASP" -->
<!--#include file="FORMAT.ASP" -->
<!--#include file="lib/delgb.asp" -->
<!--#include file="lib/error.asp" -->
<!--#include file="lib/gbfooter.asp" -->
<link rel="stylesheet" href="<%=themepath%>/gbstyle.css" type="text/css">
<%
dim founderr,errmsg
errmsg=""
founterr=false

if trim(replace(request.form("adminpwd"),"'",""))<>"" then
dim isadmin
isadmin=false
opengb
sqla="select * from admin"
set rsa=conn.execute(sqla)
  if trim(replace(request.form("adminpwd"),"'",""))=rsa("admin_password") then
    isadmin=true
  else
    isadmin=false
rsa.close
set rsa=nothing
errmsg=errmsg+"<br>"+"<li>你没有相应的操作权限!"
call diserror()
response.end
end if
end if

if isadmin then
if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB_gb)
  MM_editTable = "gb"
  MM_editColumn = "gb_id"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "guestbook.asp"
 
End If

' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql delete statement
  MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

openadmin
    sql="update allcount set gbcount = gbcount - 1"
    conn.execute(sql)
    closedatabase

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
end if


call chkparam()
if founderr then
  call diserror()
else
  call delgb()
  call endpage()
end if

rem -------------------
rem ----检查URL参数----
rem -------------------
sub chkparam()
if request.querystring("gb_id")<>"" then
  if not isInteger(request.querystring("gb_id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的留言id。"
  end if
else
    founderr=true
    errmsg=errmsg+"<br>"+"<li>请指定要删除的留言。"
end if
end sub
%>

提示标题错!


地主 发表时间: 03-12-28 16:52

回复: huarongdao [huarongdao]   论坛用户   登录
能不能说明白一点,什么标题错





我的QQ4 1307973


B1层 发表时间: 03-12-29 22:41

回复: xinnv [xinnv]   论坛用户   登录
config的代码?

B2层 发表时间: 04-01-01 04:05

回复: lincoln [lincoln]   论坛用户   登录
响应对象 错误 'ASP 0156 : 80004005'

标题错

/firelily/del_gb.asp, 行64

HTTP 标题已经写入到 客户浏览器。任何 HTTP 标题的修改必须在写入页内容之前。


源文件代码如下<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="CONFIG.ASP" -->
<!--#include file="CONN.ASP" -->
<!--#include file="FORMAT.ASP" -->
<!--#include file="lib/delgb.asp" -->
<!--#include file="lib/error.asp" -->
<!--#include file="lib/gbfooter.asp" -->
<link rel="stylesheet" href="<%=themepath%>/gbstyle.css" type="text/css">
<%
dim founderr,errmsg
errmsg=""
founterr=false

if trim(replace(request.form("adminpwd"),"'",""))<>"" then
dim isadmin
isadmin=false
opengb
sqla="select * from admin"
set rsa=conn.execute(sqla)
  if trim(replace(request.form("adminpwd"),"'",""))=rsa("admin_password") then
    isadmin=true
  else
    isadmin=false
rsa.close
set rsa=nothing
errmsg=errmsg+"<br>"+"<li>你没有相应的操作权限!"
call diserror()
response.end
end if
end if

if isadmin then
if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB_gb)
  MM_editTable = "gb"
  MM_editColumn = "gb_id"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "guestbook.asp"
 
End If

' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql delete statement
  MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

openadmin
    sql="update allcount set gbcount = gbcount - 1"
    conn.execute(sql)
    closedatabase

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
end if


call chkparam()
if founderr then
  call diserror()
else
  call delgb()
  call endpage()
end if

rem -------------------
rem ----检查URL参数----
rem -------------------
sub chkparam()
if request.querystring("gb_id")<>"" then
  if not isInteger(request.querystring("gb_id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的留言id。"
  end if
else
    founderr=true
    errmsg=errmsg+"<br>"+"<li>请指定要删除的留言。"
end if
end sub
%>


B3层 发表时间: 04-01-05 06:29

回复: 286 [unique]   版主   登录
/firelily/del_gb.asp, 行64

HTTP 标题已经写入到 客户浏览器。任何 HTTP 标题的修改必须在写入页内容之前。


贴del_gb.asp。

B4层 发表时间: 04-01-07 10:15

回复: lincoln [lincoln]   论坛用户   登录
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="CONFIG.ASP" -->
<!--#include file="CONN.ASP" -->
<!--#include file="FORMAT.ASP" -->
<!--#include file="lib/delgb.asp" -->
<!--#include file="lib/error.asp" -->
<!--#include file="lib/gbfooter.asp" -->
<title><%=webname%>留言簿</title>
<link rel="stylesheet" href="<%=themepath%>/gbstyle.css" type="text/css">
<%
dim founderr,errmsg
errmsg=""
founterr=false

if trim(replace(request.form("adminpwd"),"'",""))<>"" then
dim isadmin
isadmin=false
opengb
sqla="select * from admin"
set rsa=conn.execute(sqla)
  if trim(replace(request.form("adminpwd"),"'",""))=rsa("admin_password") then
    isadmin=true
  else
    isadmin=false
rsa.close
set rsa=nothing
errmsg=errmsg+"<br>"+"<li>你没有相应的操作权限!"
call diserror()
response.end
end if
end if

if isadmin then
if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB_gb)
  MM_editTable = "gb"
  MM_editColumn = "gb_id"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "guestbook.asp"
 
End If

' *** Delete Record: construct a sql delete statement and execute it

If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql delete statement
  MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

  If (Not MM_abortEdit) Then
    ' execute the delete
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

openadmin
    sql="update allcount set gbcount = gbcount - 1"
    conn.execute(sql)
    closedatabase

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
end if


call chkparam()
if founderr then
  call diserror()
else
  call delgb()
  call endpage()
end if

rem -------------------
rem ----检查URL参数----
rem -------------------
sub chkparam()
if request.querystring("gb_id")<>"" then
  if not isInteger(request.querystring("gb_id")) then
    founderr=true
    errmsg=errmsg+"<br>"+"<li>非法的留言id。"
  end if
else
    founderr=true
    errmsg=errmsg+"<br>"+"<li>请指定要删除的留言。"
end if
end sub
%>


这个就是啦。。。。
小老大口气不小呢。。一来就叫我帖!!
谢谢啦。

B5层 发表时间: 04-01-07 15:01

回复: combook [combook]   论坛用户   登录
在被包含的文件中写入了,
<title>**</title>

还有就是你这个页是从<script language="vbscript">
开头的吗?

B6层 发表时间: 04-01-12 22:47

回复: wuhuan [wuhuan]   论坛用户   登录
Response.Redirect(MM_editRedirectUrl)
错在这里
应该在文件开头出把缓冲区打开或者把这句改为JS脚本写

B7层 发表时间: 04-01-13 22:02

回复: lincoln [lincoln]   论坛用户   登录
小弟对此乃七窍通了六窍,恳请赐教!・・・


B8层 发表时间: 04-01-17 00:59

回复: TomyXu [tomyxu]   论坛用户   登录
强悍啊。我比起来就啥都不是了。

B9层 发表时间: 04-01-17 18:43

回复: wuhuan [wuhuan]   论坛用户   登录
在代码最开头加上
<%
response.buffer=true
%>

B10层 发表时间: 04-01-18 13:41

回复: lincoln [lincoln]   论坛用户   登录
谢谢

B11层 发表时间: 04-01-27 06:23

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号