运行时有如下的错误提示:
Microsoft JScript 运行时错误 错误 '800a1391'
'server' 未定义
D:\MYWEB\_PRIVATE\PR\SHIPING\../../../Connections/conn.asp, 行8
请各位帮帮我,为什么会出错?
我看不错误,我将原代码贴出来,请版主再帮我看一下。谢谢。 <%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%> <!--#include file="../../../Connections/conn.asp" --> <% // *** Edit Operations: declare variables
// set the form action variable var MM_editAction = Request.ServerVariables("SCRIPT_NAME"); if (Request.QueryString) { MM_editAction += "?" + Request.QueryString; }
// boolean to abort record edit var MM_abortEdit = false;
// query string to execute var MM_editQuery = ""; %> <% // *** Redirect if username exists var MM_flag="MM_insert"; if (String(Request(MM_flag)) != "undefined") { var MM_dupKeyRedirect="regisbad.htm"; var MM_rsKeyConnection=MM_conn_STRING; var MM_dupKeyUsernameValue = String(Request.Form("name")); var MM_dupKeySQL = "SELECT name FROM user WHERE name='" + MM_dupKeyUsernameValue + "'" var MM_adodbRecordset = "ADODB.Recordset"; var MM_rsKey = Server.CreateObject(MM_adodbRecordset); MM_rsKey.ActiveConnection = MM_rsKeyConnection; MM_rsKey.Source = MM_dupKeySQL; MM_rsKey.CursorType=0; MM_rsKey.CursorLocation=2; MM_rsKey.LockType=3; MM_rsKey.Open(); if (!MM_rsKey.EOF || !MM_rsKey.BOF) { // the username was found - can not add the requested username var MM_qsChar = "?"; if (MM_dupKeyRedirect.indexOf("?") >= 0) MM_qsChar = "&"; MM_dupKeyRedirect = MM_dupKeyRedirect + MM_qsChar + "requsername=" + MM_dupKeyUsernameValue; Response.Redirect(MM_dupKeyRedirect); } MM_rsKey.Close(); } %> <% // *** Insert Record: set variables
if (String(Request("MM_insert")) == "form2") {
var MM_editConnection = MM_conn_STRING; var MM_editTable = "user"; var MM_editRedirectUrl = "regisok.htm"; var MM_fieldsStr = "name|value|pws|value|email|value|questiom|value|answer|value|oicq|value|icq|value|msn|value|url|value"; var MM_columnsStr = "name|',none,''|pwd|',none,''|email|',none,''|question|',none,''|answer|',none,''|oicq|none,none,NULL|msn|none,none,NULL|msn|',none,''|url|',none,''";
// create the MM_fields and MM_columns arrays var MM_fields = MM_fieldsStr.split("|"); var MM_columns = MM_columnsStr.split("|"); // set the form values for (var i=0; i+1 < MM_fields.length; i+=2) { MM_fields[i+1] = String(Request.Form(MM_fields[i])); }
// append the query string to the redirect URL if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) { MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString; } } %> <% // *** Insert Record: construct a sql insert statement and execute it
if (String(Request("MM_insert")) != "undefined") {
// create the sql insert statement var MM_tableValues = "", MM_dbValues = ""; for (var i=0; i+1 < MM_fields.length; i+=2) { var formVal = MM_fields[i+1]; var MM_typesArray = MM_columns[i+1].split(","); var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : ""; var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : ""; var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : ""; if (formVal == "" || formVal == "undefined") { formVal = emptyVal; } else { if (altVal != "") { formVal = altVal; } else if (delim == "'") { // escape quotes formVal = "'" + formVal.replace(/'/g,"''") + "'"; } else { formVal = delim + formVal + delim; } } MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i]; MM_dbValues += ((i != 0) ? "," : "") + formVal; } MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";
if (!MM_abortEdit) { // execute the insert var MM_editCmd = Server.CreateObject('ADODB.Command'); MM_editCmd.ActiveConnection = MM_editConnection; MM_editCmd.CommandText = MM_editQuery; MM_editCmd.Execute(); MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) { Response.Redirect(MM_editRedirectUrl); } }
} %> <% var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_conn_STRING; Recordset1.Source = "SELECT * FROM user"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_findObj(n, d) { file://v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_validateForm() { file://v4.0 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=MM_findObj(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 == ''); } file://--> </script> </head>
<body> <form action="<%=MM_editAction%>" method="POST" name="form2" onSubmit="MM_validateForm('textfield2','','R','textfield3','','R');return document.MM_returnValue"> <table width="95%" border="1" cellspacing="1" cellpadding="1"> <tr> <td>用户名:</td> <td> <input name="name" type="text" id="name" onBlur="MM_validateForm('textfield','','R','textfield2','','R','textfield3','','NisEmail','textfield6','','NisNum','textfield7','','NisNum');return document.MM_returnValue"></td> </tr> <tr> <td>密码:</td> <td> <input name="pws" type="password" id="pws"></td> </tr> <tr> <td>电子邮件:</td> <td> <input name="email" type="text" id="email" onBlur="MM_validateForm('textfield3','','NisEmail');return document.MM_returnValue"></td> </tr> <tr> <td>密码提示问题:</td> <td> <input name="questiom" type="text" id="questiom"></td> </tr> <tr> <td>密码提示答案:</td> <td> <input name="answer" type="text" id="answer"></td> </tr> <tr> <td>oicq:</td> <td> <input name="oicq" type="text" id="oicq"></td> </tr> <tr> <td>icq:</td> <td> <input name="icq" type="text" id="icq"></td> </tr> <tr> <td>msn:</td> <td> <input name="msn" type="text" id="msn"></td> </tr> <tr> <td>url:</td> <td> <input name="url" type="text" id="url"></td> </tr> <tr> <td colspan="2"> <div align="right"> <input type="reset" name="Submit" value="重置"> <input type="submit" name="Submit2" value="提交"> </div></td> </tr> </table> <input type="hidden" name="MM_insert" value="form2"> </form>
</body> </html> <% Recordset1.Close(); %>