看下添加文章+文件上传的代码错误和纠正!
错误类型: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"> </td>
<td colspan="3" class="STYLE2"> </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"> </td>
<td colspan="3" class="STYLE2"> </td>
</tr>
<tr>
<td class="STYLE2"> </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> </p>
</body>
</html>
谢谢了!