Beginning Dreamweaver MX Ch10 p364
After inserting the code on pages 364 and 365 when i run the page i get the error
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/thesoccersite/backuplogin.asp, line 54, column 41
arrTemp(1) = Request.Form("txtPassword") Then
----------------------------------------^
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Page:
GET /thesoccersite/backuplogin.asp
I have checked my file against the book and the reference file in the zip from this site, but i cannot see my error. Also when i try putting the reference file from the zip in place of my file it gives the error
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/thesoccersite/login.asp, line 71, column 56
"Login failed. Please type a valid username and password
-------------------------------------------------------^
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Page:
GET /thesoccersite/login.asp
As neither file works i'm beginning to wonder if this could possibly be a problem with my setup, not the code. I have MX2004, XP Pro with ISS, and norton internet security 2004. If anyone can see my error and help me along i would be grateful. My code creating the error looks like this
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Dim sErrorMessage
Dim sReferrer
If Request.Form("txtReferrer") = "" Then
sReferrer = Request.QueryString("(accessdenied")
Else
sReferrer = Request.Form("txtReferrer")
End If
If sReferrer = "" Then
sReferrer = "admin/admin.asp"
End If
If Request.Form("txtUserName") <> "" And _
Request.Form("txtPassword") <> "" Then
Const ForReading = 1
Dim oFileSystemObject
Dim oTextStream
Dim sFileLocation
Dim sTempString
Dim arrTemp
Dim bUserFound
sFileLocation = Server.MapPath("tools/users.txt")
' Create an instance of the FileSystemObject
Set oFileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
' Create a reference to our text file so we can read from it
Set oTextStream = oFileSystemObject.OpenTextFile(sFileLocation, ForReading)
' Read in each line until we reach the end of the file
Do While (Not oTextStream.AtEndOfStream = True)
' Read a line
sTempString = oTextStream.ReadLine()
' If the line contains text
If Len(sTempString) > 0 Then
' The line should hold the username and password, seperated by a tab
' Split the line based on a taba, so we get the username and password
' in two seperate array elements
arrTemp = Split(sTempString, vbTab)
If IsArray(arrTemp) Then
' An Ubound of 1 means two elements in the array, the username
' and the password. If we haven't found both, we do not continue
If Ubound(arrTemp) = 1 Then
' Compare array elements with username and password
If arrTemp(0) = Request.Form("txtUserName" And _
arrTemp(1) = Request.Form("txtPassword") Then
bUserFound = True
Exit Do
End If
End If
End If
End If
Loop
' Close our textstream and clean up our objects
oTextStream.Close
set oTextStream = Nothing
Set oFileSystemObject = Nothing
If bUserFound = True Then
Session("MM_Username") = Request.Form("txtUserName")
Response.Redirect(sReferrer)
Else
sErrorMessage = "<span class=""clsErrorMessage""><br>" & _
"Login failed. Please type a valid username and password</span>"
End If
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Login to GlobalSoccerEvents.com - Your Source for Soccer Events Around the Globe</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //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() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.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 == '');
}
//-->
</script>
<link href="Styles/mainStyles.css" rel="stylesheet" type="text/css">
</head>
<body><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="Images/logo.gif"></td>
<td><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="home.asp" id="home">Home</a></td>
<td> </td>
<td><a href="events.asp" id="events">Events</a></td>
<td> </td>
<td><a href="mysite.asp" id="mysite">My Site</a></td>
<td> </td>
<td><a href="login.asp" id="login">Login</a></td>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<script language="javascript" type="text/javascript">
var sPageName = '<%=Request.ServerVariables("SCRIPT_NAME")%>';
sPageName = sPageName.substr(sPageName.lastIndexOf('/') + 1).toLowerCase();
sPageName = sPageName.substr(0, sPageName.lastIndexOf('.'));
if (document.getElementById(sPageName))
{
document.getElementById(sPageName).style.fontWeigh t = 'Bold';
document.getElementById(sPageName).style.fontSize = '14pt';
}
</script><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<h2>Login to GlobalSoccerEvents.com </h2>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td>Please type your Username and Password, then click the Login button
<%= sErrorMessage %></td>
</tr>
<tr>
<td width="100%" bgcolor="#CCCCCC" colspan="2">
<form action="login.asp" method="post" name="frmLogin" onSubmit="MM_validateForm('txtUserName','','R','tx tPassword','','R');return document.MM_returnValue">
<p>Username<br>
<input name="txtUserName" type="text" class="clsTextInput" id="txtUserName" style="width:150px;">
</p>
<p>Password<br>
<input name="txtPassword" type="password" class="clsTextInput" id="txtPassword" style="width:150px;">
</p>
<p>
<input name="BtnLogin" type="submit" id="BtnLogin" value="Login">
</p>
<input name="txtReferrer" type="hidden" value="<%=sReferrer%>"></form>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><br>
<br>
<br>
<br>
<br>
</td>
</tr>
</table>
</body>
</html>
|