Forums

ASP

This topic is locked

Type mismatch: 'UBound'

Posted 17 Oct 2003 21:07:51
1
has voted
17 Oct 2003 21:07:51 Janusz Jasinski posted:
As far as I can see, it is adding items to the basket ok but I think there is a problem with the array when you try to checkout. Once the items are in the basket, it should pass to the buy page and then it uses the asptophp.asp and phpreceiveasp.php files to pass the required fields to wordpay.

The file that is throwing up the error is this file:

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
&lt;%

if not Session("boolstart" then
Session("total"=0
Session("type"=Array(""
Session("qty"=Array(""
Session("diameter" = Array(""
Session("rod" = Array(""
Session("length" = Array(""
Session("finish" = Array(""
Session("price" = Array(""
Session("boolstart" = true
end if

enablesessionstate=true
function datetoString()
dim theDate, strDate
strDate = ""
thedate = CStr(CDbl(Now))
for n = 1 to len(theDate)
strDate = strDate & CStr(Asc(Mid(theDate,n,1)))
next
datetoString = strDate
end function

sub logout
Session("srsession" = datetoString()
Session("email" = ""
Session("dealname" = ""
Session("password" = ""
Session("customer" = ""
end sub

sub emptybasket
Session("total"=0
Session("type"=Array(""
Session("qty"=Array(""
Session("diameter" = Array(""
Session("rod" = Array(""
Session("length" = Array(""
Session("finish" = Array(""
Session("price" = Array(""
Session("boolstart" = true
end sub

sub addItem(qty, typ, diam, rod, length, fin, price)
Session("qty"=incArray(Session("qty", qty)
Session("type"=incArray(Session("type", typ)
Session("diameter"=incArray(Session("diameter", diam)
Session("rod"=incArray(Session("rod", rod)
Session("length"=incArray(Session("length", length)
Session("finish"= incArray(Session("finish", fin)
Session("price"= incArray(Session("price", price)
end sub

function incArray(list, val)
dim count
count = UBound(list)
Redim Preserve list(count+1)
list(count+1) = val
incArray = list
end function

sub writeArrays()
'write out all values for output to php
writeArray
emptybasket
end sub

sub writeSession()
Response.Write "&lt;input type='hidden' "
Response.Write "name='srsession'"
Response.Write "value='"
Response.Write Session("srsession"
Response.Write "' &gt;"
Response.Write "&lt;br&gt;"
end sub

sub writeTotal()
Response.Write "&lt;input type='hidden' "
Response.Write "name='total'"
Response.Write "value='"
Response.Write Session("total"
Response.Write "' &gt;"
Response.Write "&lt;br&gt;"
end sub

sub writeArray()
dim count
listarray=Session("area"
count = UBound(listarray)

dim lcount , item ,qlist ,tlist ,dlist ,rlist ,flist ,llist, plist, selcol
qlist = Session("qty"
tlist = Session("type"
dlist = Session("diameter"
rlist = Session("rod"
llist = Session("length"
flist = Session("finish"
plist = Session("price"
lcount = UBound(alist)
for item = 1 to lcount

total = plist(item) * qlist(item)
writeHidden "qty", qlist(item), item
writeHidden "type", tlist(item), item
writeHidden "diameter", dlist(item), item
writeHidden "rod", rlist(item), item
writeHidden "length", llist(item), item
writeHidden "finish", flist(item), item
writeHidden "price", plist(item), item
writeHidden "total", total, item
Response.Write "&lt;br&gt;"
next
end sub

sub writeHidden(itemname, itemvalue, count)
Response.Write "&lt;input type='hidden' "
Response.Write "name='"
Response.Write itemname & count
Response.Write "' "
Response.Write "value='"
Response.Write itemvalue
Response.Write "' &gt;"
end sub


sub modifyqty(item, qty)
dim list, count
list = Session("qty"
count = UBound(list)
if item &lt;= count then
list(item) = qty
Session("qty"=list
end if
end sub

sub remItem(item)
Session("qty"=decArray(Session("qty", item)
Session("type"=decArray(Session("type", item)
Session("diameter"=decArray(Session("diameter", item)
Session("rod"=decArray(Session("rod", item)
Session("length"=decArray(Session("length", item)
Session("finish"= decArray(Session("finish", item)
Session("price"= decArray(Session("price", item)
end sub


function decArray(list, item)
'remove item from array
'reduce array size
dim count, n
count = UBound(list)
if item &lt;=count then
for n= item to count -1
list(n) = list (n+1)
next
Redim Preserve list(count-1)
end if
decArray = list
end function

function toNBSP(item)
if item=" " or item="-" or item = "0" then
item = "&nbsp;"
end if
toNBSP = item
end function

function getPrice(item, length, diam, run)

end function

function getCartID()
Dim rsMaxID
Dim rsMaxID_numRows

Set rsMaxID = Server.CreateObject("ADODB.Recordset"
rsMaxID.ActiveConnection = MM_portal_STRING
rsMaxID.Source = "SELECT MAX(id) as MaxID FROM cart"
rsMaxID.CursorType = 0
rsMaxID.CursorLocation = 2
rsMaxID.LockType = 1
rsMaxID.Open()

rsMaxID_numRows = 0
Dim cartID
if (rsMaxID.Fields.Item("MaxID".Value) &lt;&gt; "" then
cartID = CInt((rsMaxID.Fields.Item("MaxID".Value))+1
else
cartID = 1
end if
getCartID = cartID
end function
%&gt;
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

It throws up this error:

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/shop/shop.asp, line 92 <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Please can someone help.

Janusz

======================
janusz.monkey-it.co.uk

Reply to this topic