| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:看下添加文章+文件上传的代码错误和纠正!
只看楼主 加入收藏
无忧当当
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2008-7-9
结帖率:100%
收藏
 问题点数:0 回复次数:2 
看下添加文章+文件上传的代码错误和纠正!
错误类型:
Microsoft VBScript 编译器错误 (0x800A0411)
名称重定义
/08ji/admin/addwenjian.asp, line 59, column 4
Dim MM_editCmd
---^


代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/wenjian.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject (")
    MM_editCmd.ActiveConnection = MM_wenjian_STRING
    MM_ = "INSERT INTO wenjian (title, author, addtime, content) VALUES (?, ?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("title")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 18, Request.Form("author")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 135, 1, -1, MM_IIF(Request.Form("addtime"), Request.Form("addtime"), null)) ' adDBTimeStamp
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 200, Request.Form("content")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "../wenjian/list.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd
    Set MM_editCmd = Server.CreateObject (")
    MM_editCmd.ActiveConnection = MM_wenjian_STRING
    MM_ = "INSERT INTO download (filename, fileurl, filesite, filetype) VALUES (?, ?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("filename")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 200, Request.Form("fileurl")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("filesite")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("filetype")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "../wenjian/list.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE3 {font-size: 9pt; font-family: "宋体"; }
.STYLE4 {
    color: #FF0000;
    font-weight: bold;
}
.url_menu {
    font-family: "宋体";
    font-size: 9pt;
    color: #000000;
    text-decoration: none;
}
-->
</style>
<link href="main.css" rel="stylesheet" type="text/css" />
<link href="../main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>

<body>
<p class="STYLE4">当前位置:添加班级文件</p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1">
  <table width="661" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="64" class="STYLE2">文件标题</td>
      <td colspan="3" class="STYLE2"><label>
        <input name="title" type="text" id="title" size="50" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">发布者</td>
      <td colspan="3" class="STYLE2"><label>
        <input name="author" type="text" disabled="disabled" id="author" value="网站管理者" size="20" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">发布时间</td>
      <td colspan="3" class="STYLE2"><label>
        <input name="addtime" type="text" disabled="disabled" class="STYLE2" id="addtime" value="<%response.write(date())%>" size="15" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">内容</td>
      <td colspan="3" class="STYLE2"><label>
        <textarea name="content" cols="70" rows="10" id="content"></textarea>
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">&nbsp;</td>
      <td colspan="3" class="STYLE2">&nbsp;</td>
    </tr>
    <tr>
      <td class="STYLE2">附件名称</td>
      <td colspan="3" class="STYLE2"><label>
        <input name="filename" type="text" id="filename" size="50" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">附件地址</td>
      <td colspan="3" class="STYLE2"><label>
        <input name="fileurl" type="text" id="fileurl" size="50" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">附件大小</td>
      <td width="245" class="STYLE2"><label>
        <input name="filesite" type="text" class="STYLE2" id="filesite" value="? MB/KB" />
      </label></td>
      <td width="93" align="center" class="STYLE2">附件类型</td>
      <td width="259" class="STYLE2"><label>
      <input name="filetype" type="text" class="STYLE2" id="filetype" value=".doc/.xls/.ppt/.chm/..." size="30" />
      </label></td>
    </tr>
    <tr>
      <td class="STYLE2">&nbsp;</td>
      <td colspan="3" class="STYLE2">&nbsp;</td>
    </tr>
    <tr>
      <td class="STYLE2">&nbsp;</td>
      <td colspan="3" class="STYLE2"><label>
                        
            <input name="button" type="submit" id="button" onclick="MM_validateForm('title','','R','author','','R','addtime','','R','content','','R');return document.MM_returnValue" value="提交" />
      </label>
        <label>
        <input type="reset" name="button2" id="button2" value="重置" />
      </label></td>
    </tr>
  </table>

  

  

  

  

  

    <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp; </p>
</body>
</html>


谢谢了!
搜索更多相关主题的帖子: 代码 文件 
2008-07-10 15:13
无忧当当
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2008-7-9
收藏
得分:0 
快来看看啊~~~呵呵
2008-07-10 15:51
towering
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:261
专家分:507
注 册:2007-10-9
收藏
得分:0 
怎么又是你呀?
你在做什么呀?
学习用DW CS3做东东?

出现名称重定义说明这个变量之前已经定义过了,
而你是用DW自动生成的代码,并没有自己定义,
这很可能是由于你之前已经用过一次服务器的插入行为了,
DW自动生成的代码不好分析,
最快最好的方法还是像昨天说的那样:
清除所有服务器行为重建!

试试多学习吧!
学习愉快!

[[it] 本帖最后由 towering 于 2008-7-10 16:03 编辑 [/it]]
2008-07-10 16:02
快速回复:看下添加文章+文件上传的代码错误和纠正!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021646 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved