Hi All,
I'm having problems with an Array being stored in a session variable.
It has no problem adding one element, but falls over when I try to add a second, saying there is a type mismatch on line 10.
On line 10 I am saying that if the session is not empty, make myArray equal to it. It obviously see's these 2 types as being incompatible.
Any help would be greatly appreciated, this is driving me mad!
I've put a copy online at
if you fancy a look...
Please find the code below:
<%
'variabels
Dim i, x, z
Dim rows, newrows
Dim myArray()
reDim myArray(3,0)
Dim product, quant, price
if not isEmpty(session("cart")) then 'if the session is empty
myArray=Session("cart") 'LINE 10 !!!
rows=UBound(myArray,2)
newrows=rows+1
End If
product = Request.Form("product")
quant = Request.Form("quant")
price = Request.Form("price")
if not product="" or not quant="" or not price="" then
reDim Preserve myArray(3,newrows) 'redimension the array
myArray(0,newrows)=product
myArray(1,newrows)=quant
myArray(2,newrows)=price
session("cart")=myArray
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Session test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h4>::Session Variable Test::</h4>
<form id="frmarray" name="arrayform" method="post" action="session.asp">
<input type="text" id="product" name="product" /><br />
<input type="text" id="quant" name="quant" /><br />
<input type="text" id="price" name="price" /><br />
<input type="submit" id="submit" value="Go Baby Go" />
</form>
<%
if isEmpty(Session("cart")) then
Response.Write("nothing in cart")
else %>
<p>There are <%=rows %> elements in this array</p><%
for i = 0 to rows
for x = 0 to 2
Response.Write(":"&myArray(x,i)&" ")
next
Response.Write("<br/>")
next
End If
%>
<br /><a href="abandon.asp">abandon session</a>
</body>
</html>
I'm having problems with an Array being stored in a session variable.
It has no problem adding one element, but falls over when I try to add a second, saying there is a type mismatch on line 10.
On line 10 I am saying that if the session is not empty, make myArray equal to it. It obviously see's these 2 types as being incompatible.
Any help would be greatly appreciated, this is driving me mad!
I've put a copy online at
if you fancy a look...
Please find the code below:
<%
'variabels
Dim i, x, z
Dim rows, newrows
Dim myArray()
reDim myArray(3,0)
Dim product, quant, price
if not isEmpty(session("cart")) then 'if the session is empty
myArray=Session("cart") 'LINE 10 !!!
rows=UBound(myArray,2)
newrows=rows+1
End If
product = Request.Form("product")
quant = Request.Form("quant")
price = Request.Form("price")
if not product="" or not quant="" or not price="" then
reDim Preserve myArray(3,newrows) 'redimension the array
myArray(0,newrows)=product
myArray(1,newrows)=quant
myArray(2,newrows)=price
session("cart")=myArray
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Session test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h4>::Session Variable Test::</h4>
<form id="frmarray" name="arrayform" method="post" action="session.asp">
<input type="text" id="product" name="product" /><br />
<input type="text" id="quant" name="quant" /><br />
<input type="text" id="price" name="price" /><br />
<input type="submit" id="submit" value="Go Baby Go" />
</form>
<%
if isEmpty(Session("cart")) then
Response.Write("nothing in cart")
else %>
<p>There are <%=rows %> elements in this array</p><%
for i = 0 to rows
for x = 0 to 2
Response.Write(":"&myArray(x,i)&" ")
next
Response.Write("<br/>")
next
End If
%>
<br /><a href="abandon.asp">abandon session</a>
</body>
</html>