Hi I'm hoping someone might be able to help me out. For the last few days I've been building a seating manager for a LAN party. Finally got it all working today only to find that after a few seat changes the ASP pages grind to a halt. What I don't get is why it works so quickly the first few times and then just stops altogether (all asp pages then seem to stop working, including other on the site, after I restart the browser it works fine again). This lead me to believe that my ASP was somehow messing with my browser not the server.
My first suspicion was the amount of code on the "reserve a seat" page. I check a session variable to see if the user already has a seat, then redirects them if that is the case. I then check to see if the seat they want is actually available (as seat id is sent via querystring). I then have the update code and finally I call a function which converts the seat ID into a "seat name" (some simple ASP which reformats the ID from 5 to A05 etc).
If the user has a seat, that seat is deleted on another page, and the session variable reset to allow for a new seat reservation. The user is then redirected back to the reserve a seat page with their original seat id. I was wondering if rapid changing of seats, hence rapid changing the value of a session variable might be causing the problem?
Otherwise I also have a total of 5 sessions variables going at the same time. Might this make an impact on the server performance, could this possibly be the cause for the site to start fast but then just stop?
Here is the url so you can see the problem yourself. First click here to create the session variables to log you in.
Then here to use the acctual seating utility.
I have included the code for the page (commented) which keeps freezing. This page does the reservering. It updates a database which has a table with one seat per field. Each row contains the seat ID, userID, userName, userClan and userClanID.
If anyone can shed some light on this issues it would be greatly appreciated!
Thanks in advance!
Nik
nik@meltdown.ca
<%@LANGUAGE="VBSCRIPT"%>
<%' check if sessions exist, if loged in%>
<!--#include file="ax_secure.asp" -->
<!--#include file="../Connections/meltdown.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "#"
If (request.querystring("id"
<> ""
Then
Recordset1__MMColParam = request.querystring("id"
End If
%>
<%
'Check if session seat = no, if they have a seat they need to delete it first
If Session("seat"
<> "no" then response.redirect("del.asp?id=" & Recordset1__MMColParam)
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_meltdown_STRING
Recordset1.Source = "SELECT * FROM floor WHERE id = " + Replace(Recordset1__MMColParam, "'", "''"
+ ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim seat_user_id
seat_user_id = Recordset1.Fields.Item("user_id"
.Value
if seat_user_id = 0 Then 'seat is free, no 1337 querystring hax0ring here
%>
<%
'I dont need to make this pull from the db, dont know why I did, in anycase I dont think this is causing the problem
'Define ID for later manipulation of the seat name
id = (Recordset1.Fields.Item("id"
.Value)
%>
<%
'Start UD super bulky Update code
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"
)
If (Request.QueryString <> ""
Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update"
) = "form1" And CStr(Request("MM_recordId"
) <> ""
Then
MM_editConnection = MM_meltdown_STRING
MM_editTable = "floor"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId"
+ ""
MM_editRedirectUrl = "done.asp"
MM_fieldsStr = "user_id|value|user_name|value|user_clan|value|user_clan_id|value"
MM_columnsStr = "user_id|none,none,NULL|user_name|',none,''|user_clan|',none,''|user_clan_id|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> ""
Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""
Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update"
) <> "" And CStr(Request("MM_recordId"
) <> ""
Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none"
Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none"
Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none"
Then MM_emptyVal = ""
If (MM_formVal = ""
Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> ""
Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'"
Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''"
& "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Session("seat"
= ""
If (MM_editRedirectUrl <> ""
Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%End If 'end if seat acctually free%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%'include fuctions to format seat id%>
<!--#include file="ax_formatseat.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FF9900" text="#510000" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="187" height="407" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<%If user_seat_id <> 0 Then 'make sure seat is still available%>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Uh oh! It seems
that someone has already taken this seat! Please click <a href="floor.asp" target="main">here</a>
to refresh the seating plan.</font>
<%Else ' seat is available, no 1337 querystring hax0rs here%>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">You have
chosen seat <strong><%=seatname(id)%> </strong><font size="1">(code: <%=id%>)<font size="2">.</font></font></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">To reserve
this seat click on the button below. You can change your seat as many
times as you wish. Seating reservation will close 24 hours prior to the
LAN.</font></p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
<div align="center">
<input name="id" type="hidden" id="id" value="<%=id%>">
<input name="user_id" type="hidden" id="user_id" value="<%=session("user_id"
%>">
<input name="user_name" type="hidden" id="user_name" value="<%=session("user_name"
%>">
<input name="user_clan" type="hidden" id="user_id" value="<%=session("user_clan"
%>">
<input name="user_clan_id" type="hidden" id="user_name" value="<%=session("user_clan_id"
%>">
<input type="submit" name="Submit" value="Reserve my seat">
<br>
<font size="1" face="Arial, Helvetica, sans-serif">(Please be patient)</font>
</div>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=id%>">
</form>
<%End If 'end if 1337 haxor or not%>
</td>
</tr>
<tr>
<td height="20%"><!--#include file="ax_bottom.asp" --></td>
</tr>
</table>
</body>
</html>
Referring URL 1: Referring URL 2:
My first suspicion was the amount of code on the "reserve a seat" page. I check a session variable to see if the user already has a seat, then redirects them if that is the case. I then check to see if the seat they want is actually available (as seat id is sent via querystring). I then have the update code and finally I call a function which converts the seat ID into a "seat name" (some simple ASP which reformats the ID from 5 to A05 etc).
If the user has a seat, that seat is deleted on another page, and the session variable reset to allow for a new seat reservation. The user is then redirected back to the reserve a seat page with their original seat id. I was wondering if rapid changing of seats, hence rapid changing the value of a session variable might be causing the problem?
Otherwise I also have a total of 5 sessions variables going at the same time. Might this make an impact on the server performance, could this possibly be the cause for the site to start fast but then just stop?
Here is the url so you can see the problem yourself. First click here to create the session variables to log you in.
Then here to use the acctual seating utility.
I have included the code for the page (commented) which keeps freezing. This page does the reservering. It updates a database which has a table with one seat per field. Each row contains the seat ID, userID, userName, userClan and userClanID.
If anyone can shed some light on this issues it would be greatly appreciated!
Thanks in advance!
Nik
nik@meltdown.ca
<%@LANGUAGE="VBSCRIPT"%>
<%' check if sessions exist, if loged in%>
<!--#include file="ax_secure.asp" -->
<!--#include file="../Connections/meltdown.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "#"
If (request.querystring("id"
Recordset1__MMColParam = request.querystring("id"
End If
%>
<%
'Check if session seat = no, if they have a seat they need to delete it first
If Session("seat"
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_meltdown_STRING
Recordset1.Source = "SELECT * FROM floor WHERE id = " + Replace(Recordset1__MMColParam, "'", "''"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim seat_user_id
seat_user_id = Recordset1.Fields.Item("user_id"
if seat_user_id = 0 Then 'seat is free, no 1337 querystring hax0ring here
%>
<%
'I dont need to make this pull from the db, dont know why I did, in anycase I dont think this is causing the problem
'Define ID for later manipulation of the seat name
id = (Recordset1.Fields.Item("id"
%>
<%
'Start UD super bulky Update code
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"
If (Request.QueryString <> ""
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update"
MM_editConnection = MM_meltdown_STRING
MM_editTable = "floor"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId"
MM_editRedirectUrl = "done.asp"
MM_fieldsStr = "user_id|value|user_name|value|user_clan|value|user_clan_id|value"
MM_columnsStr = "user_id|none,none,NULL|user_name|',none,''|user_clan|',none,''|user_clan_id|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> ""
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update"
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none"
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none"
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none"
If (MM_formVal = ""
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> ""
MM_formVal = MM_altVal
ElseIf (MM_delim = "'"
MM_formVal = "'" & Replace(MM_formVal,"'","''"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
Session("seat"
If (MM_editRedirectUrl <> ""
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%End If 'end if seat acctually free%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%'include fuctions to format seat id%>
<!--#include file="ax_formatseat.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FF9900" text="#510000" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="187" height="407" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<%If user_seat_id <> 0 Then 'make sure seat is still available%>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Uh oh! It seems
that someone has already taken this seat! Please click <a href="floor.asp" target="main">here</a>
to refresh the seating plan.</font>
<%Else ' seat is available, no 1337 querystring hax0rs here%>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">You have
chosen seat <strong><%=seatname(id)%> </strong><font size="1">(code: <%=id%>)<font size="2">.</font></font></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">To reserve
this seat click on the button below. You can change your seat as many
times as you wish. Seating reservation will close 24 hours prior to the
LAN.</font></p>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
<div align="center">
<input name="id" type="hidden" id="id" value="<%=id%>">
<input name="user_id" type="hidden" id="user_id" value="<%=session("user_id"
<input name="user_name" type="hidden" id="user_name" value="<%=session("user_name"
<input name="user_clan" type="hidden" id="user_id" value="<%=session("user_clan"
<input name="user_clan_id" type="hidden" id="user_name" value="<%=session("user_clan_id"
<input type="submit" name="Submit" value="Reserve my seat">
<br>
<font size="1" face="Arial, Helvetica, sans-serif">(Please be patient)</font>
</div>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=id%>">
</form>
<%End If 'end if 1337 haxor or not%>
</td>
</tr>
<tr>
<td height="20%"><!--#include file="ax_bottom.asp" --></td>
</tr>
</table>
</body>
</html>
Referring URL 1: Referring URL 2: