求助!求助!提交出错

cutedoudou1314 2013-01-10 10:44:03
各位大神,下面是用ASP写的一个网页,调用FCK文本编辑框,点击提交按钮将文本编辑框里的内容保存到数据库database.mdb。点击读数据可以读出数据库里的内容到页面。可是为啥第一次运行这个页面点击提交总是出错,说找不到页面,点击读数据后,再写数据提交就不会出错啊?求大神帮帮忙啊!困扰好久了啊!感谢感谢!

<%@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" />
<title>无标题文档</title>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script> <!--fck编辑器加在<head>中的代码-->

</head>
<!--#include file="inc_/conn.asp"-->
<%
if request("submit")="OK" then
content=request("content")
sql="insert into content (content) values('"&content&"')"
set rs=conn.execute(sql)
response.write"<SCRIPT language=JavaScript>alert('写入成功');"
response.write"this.location.href='javascript:history.back();'</SCRIPT>"
end if
%>
<body>
<form action="?submit=OK" method="post">
<table border="1">
<tr>
<td rowspan="2" valign="top"><a href="index.asp">写数据</a>:<br /><a href="show.asp">读数据</a>:</td>
<td width="480" height="430" valign="top">
<p><!--fck编辑器加在<form>中的<script>代码-->
<script type="text/javascript">
var oFCKeditor = new FCKeditor( 'content' ) ;
oFCKeditor.Height = "420"
oFCKeditor.Create() ;
</script>
</td>
</tr>
<tr>
<td><input type="submit" value="提交"/>
</td>
</tr>
</table>
</form>
</body>
</html>
...全文
220 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
cutedoudou1314 2013-01-12
  • 打赏
  • 举报
回复
引用 9 楼 dogfish 的回复:
有那句 alert('写入成功'); 跳出来吗?
没有跳出来啊!为啥读取完一次数据,再次编辑,提交就成功呢?纠结啊
sunnyrunk 2013-01-12
  • 打赏
  • 举报
回复
<% if request("submit")="OK" then content=request("content") sql="insert into content (content) values('"&content&"')" set rs=conn.execute(sql) response.write"<SCRIPT language=JavaScript>alert('写入成功');" response.write"this.location.href='javascript:history.back();'</SCRIPT>" end if %> 你这个东西没有刷新。 response.write "window.document.location.href='这里改成上一页的URL地址';" response.write "</script>" 或是: response.write "window.document.location.href='"&Request.ServerVariables("HTTP_REFERER")&"';"
lzp4881 2013-01-12
  • 打赏
  • 举报
回复
学编程要先学会调试程序,自己设置断点,输出变量,找出问题所在,毕竟别人没有你的环境,无法为你测试,而且你又交代得不是很清楚,所以别人只能猜,不要一味依赖别人。
Dogfish 2013-01-12
  • 打赏
  • 举报
回复
有那句 alert('写入成功'); 跳出来吗?
Dogfish 2013-01-12
  • 打赏
  • 举报
回复
来个on error捕捉一下错误。 可能不是页面没有,是出错
cutedoudou1314 2013-01-11
  • 打赏
  • 举报
回复
大神出现吧!!!
cutedoudou1314 2013-01-11
  • 打赏
  • 举报
回复
引用 6 楼 lzp4881 的回复:
<% if request("submit")="OK" then content=request("content") sql="insert into content (content) values('"&content&"')" set rs=conn.execute(sql) response.write"<SCRIPT l……
还是不行啊,大神,老样子,第一次提交时出错啊
lzp4881 2013-01-11
  • 打赏
  • 举报
回复
<% if request("submit")="OK" then content=request("content") sql="insert into content (content) values('"&content&"')" set rs=conn.execute(sql) response.write"<SCRIPT language=JavaScript>alert('写入成功');" response.write"this.location.href='javascript:history.back();'</SCRIPT>" end if %> 这一段改成 <% if request.querystring("submit")="OK" then content=request("content") sql="insert into [content] ([content]) values('"&content&"')" conn.execute(sql) response.write"<SCRIPT language=JavaScript>alert('写入成功');</script>" end if %>
cutedoudou1314 2013-01-11
  • 打赏
  • 举报
回复
引用 3 楼 lzp4881 的回复:
把 if request("submit")="OK" then 改成 if request.querystring("submit")="OK" then
谢谢啊,我试了还是不行啊,每次运行要先点击读数据显示show.asp页面,再写数据提交才会成功,直接点击提交就显示找不到页面。 下面是show.asp的代码:
<%@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" />
  <script type="text/javascript" src="fckeditor/editor/dialog/InsertCode/JS/formulae.js" ></script>
<title>无标题文档</title>
</head>
<!--#include file="inc_/conn.asp"-->
<body>


<table border="1">
  <tr>
    <td rowspan="2" valign="top"><a href="index.asp">写数据</a>:<br /><a href="show.asp">读数据</a>:</td>
    <td width="460" height="430" valign="top">
	<%
content=request("content")
sql="select top 1 * from content order by ID desc "

 Set rs = Server.CreateObject("ADODB.Recordset")
 rs.open sql,conn,1,3
 if not rs.eof  then
response.Write rs("content")
else 
 response.Write("无数据")
 end if
%>
</td>
  </tr>
  <tr>
    <td > </td>
  </tr>
</table>


</body>
</html>
cutedoudou1314 2013-01-11
  • 打赏
  • 举报
回复
引用 2 楼 dong11wei 的回复:
<form action="?submit=OK" method="post">,对应的显示页面了? 改成这样: <form action="b.asp" submit=OK" method="post"> 然后在写一个b.asp,这个页面就是用来显示数据库数据的!!
你好,数据库显示页面是show.asp,提交按钮的动作只是完成把文本编辑框里的数据写入到数据库里,第一次运行总是不成功,
lzp4881 2013-01-11
  • 打赏
  • 举报
回复
把 if request("submit")="OK" then 改成 if request.querystring("submit")="OK" then
dong11wei 2013-01-11
  • 打赏
  • 举报
回复
<form action="?submit=OK" method="post">,对应的显示页面了? 改成这样: <form action="b.asp" submit=OK" method="post"> 然后在写一个b.asp,这个页面就是用来显示数据库数据的!!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧