I'm using a chat program and I keep getting an error and I can't seem to find it. I need a fresh look.
The error is:
Microsoft VBScript runtime error '800a01a8'
Object required: '[undefined]'
default.asp, line 96
The code is
<% Option Explicit %>
<!-- #include file="constants.inc" -->
<%
Dim ChatID
Dim requestedUsername
ChatID = Request("ChatID")
requestedUsername = Server.HTMLEncode( Request("username") )
' do not show login screen if a valid session exists
If (ChatID <> "") Then
Response.Redirect "chat.asp?ChatID=" & ChatID
Response.End
End If
Dim mode, x, errorMessage
mode = Request("mode")
If ( (mode = "userLogin") ) Then
If ( Len(Request("username")) < 1 ) Then
errorMessage = "You have to enter a username before starting to chat"
Else
' Check if this user exist already
requestedUsername = Left(requestedUsername, 20)
If (Not FindUser(requestedUsername
) AND (InStr(requestedUsername, "|") =
0)) Then
' we have a new chat user thus we need to create a new
' id for him/her
ChatID = CStr(Timer) ' safe enough for now
Application.Lock
Application.StaticObjects.
Item("ASPC
hat").Add ChatID,
requestedUsername
Application.StaticObjects.
Item("ASPC
hatTime").
Add ChatID,
CStr(Now())
' tell all other users about this new user'
For x = MESSAGES To 2 Step -1
Application("chatline_" & x) = Application("chatline_" &
x-1)
Next
Application("chatline_1") = "<tr><td align='right'><img
src='images/Enter.gif' height=14 width=14> </td><td><s
pan class='loggedIn'>" &
requestedUsername & " logged on at " & now & "</span></td></tr>"
Application.Unlock
' redirect to new frame window and create a new session,
' if user has enabled session
Response.Redirect "Chat.asp?ChatID=" & ChatID
Response.End
Else
errorMessage = "Sorry, but the name you chose is already in use.
Please choose another."
End If
End If
End If
%>
<html>
<head>
<title>ASPChat On·Line</title>
<link rel="stylesheet" type="text/css" href="Chat.css">
<script language="JavaScript">
<!--
function setFocus()
{
document.frmLogin.username
.focus();
}
// -->
</script>
</head>
<body topmargin="1" leftmargin="1" marginwidth="1" marginheight="1">
<form name="frmLogin" method="POST" action="Default.asp">
<input type="hidden" name="mode" value="userLogin">
<div align="center">
<center>
<table border="0" cellspacing="0" cellpadding="4" width="10">
<tr>
<td colspan="2"><span
class="Error"><%=errorMess
age%></spa
n></td>
</tr>
<tr>
<td bgcolor="#800000" colspan="2">
<b><font color="#FFFFFF"> ASPC
hatWorX
3.0</font></b>
</td>
</tr>
<tr>
<td colspan="2">
<table border="0" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td width="50%">Chat
Name </td>
<td width="50%"><input type="text"
name="username" class="editField" size="15" tabindex="1"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
<td align="right">
<input type="image" name="login" value="submit"
src="images/Chat.jpg" border="0" width="90" height="30" tabindex="2">
</td>
</tr>
<tr>
<td colspan="2"><hr noshade color="#D0D0D0" size="1"></td>
</tr>
<tr>
<td colspan="2">Current chatusers (max. <%=USERS%>):</td>
</tr>
<%
Dim arUserNames, arUserIDs, i, chatName
arUserIDs = Application.StaticObjects.
Item("ASPC
hat").Keys
arUserNames = Application.StaticObjects.
Item("ASPC
hat").Item
s
For i = 0 To Application.StaticObjects.
Item("ASPC
hat").Coun
t-1
If (ChatID = arUserIDs(i)) Then
chatName = "<b>" & arUserNames(i) & "</b>"
Else
chatName = arUserNames(i)
End If
If ( i MOD 2 ) Then
Response.Write "<tr bgcolor='#F8F8F8'>"
Else
Response.Write "<tr>"
End If
Response.Write " <td><img src='images/Chatter.gif' width=16 height=16></td>"
Response.Write " <td width='100%' class='infoText'>" & chatName & " </td>"
Response.Write "</tr>"
Next
If (Application.StaticObjects
.Item("ASP
Chat").Cou
nt = 0) Then
%>
<tr>
<td colspan="2" class="infoHeader"> &
nbsp; 
;No
users currently logged in.</td>
</tr>
<%
End If
%> </table>
</center>
</div>
</form>
<script language="JavaScript">
setFocus();
</script>
</body>
</html>