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 error in question is:
Code:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/shop/shop.asp, line 92
The 'problem file' has the following code:
Code:
<%
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 "<input type='hidden' "
Response.Write "name='srsession'"
Response.Write "value='"
Response.Write Session("srsession")
Response.Write "' >"
Response.Write "<br>"
end sub
sub writeTotal()
Response.Write "<input type='hidden' "
Response.Write "name='total'"
Response.Write "value='"
Response.Write Session("total")
Response.Write "' >"
Response.Write "<br>"
end sub
sub writeArray()
dim count
listarray=Session("area")
count = UBound(listarray) <!--THIS IS LINE 92-->
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 "<br>"
next
end sub
sub writeHidden(itemname, itemvalue, count)
Response.Write "<input type='hidden' "
Response.Write "name='"
Response.Write itemname & count
Response.Write "' "
Response.Write "value='"
Response.Write itemvalue
Response.Write "' >"
end sub
sub modifyqty(item, qty)
dim list, count
list = Session("qty")
count = UBound(list)
if item <= 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 <=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 = " "
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) <> "" then
cartID = CInt((rsMaxID.Fields.Item("MaxID").Value))+1
else
cartID = 1
end if
getCartID = cartID
end function
%>
The asptophp.asp page is as follows:
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/portal.asp" -->
<!--#include file="shop.asp" -->
<html>
<head>
<title>Contacting Worldpay</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="aspform" method="post" action="phpreceiveasp.php">
<%writeArrays%>
<input type="hidden" name="instId" value="<%=Request.Form("instId")%>">
<input type="hidden" name="cartId" value="<%Request.Form("cartId")%>">
<input type="hidden" name="cost" value="<%=Request.Form("cost")%>">
<input type="hidden" name="currency" value="<%=Request.Form("currency")%>">
<input type="hidden" name="desc" value="<%=Request.Form("desc")%>">
<input type="hidden" name="country" value="<%=Request.Form("country")%>">
<input type="hidden" name="name" value="<%=Request.Form("name")%>">
<input type="hidden" name="address" value="<%=Request.Form("address")%>">
<input type="hidden" name="postcode" value="<%=Request.Form("postcode")%>">
<input type="hidden" name="county" value="<%Request.Form("county")%>">
<input type="hidden" name="phone" value="<%=Request.Form("phone")%>">
<input type="hidden" name="email" value="<%=Request.Form("email")%>">
</form>
<script language=javascript>
document.aspform.submit();
</script>
</body>
And finally, the phpreceive.asp page is as follows:
Code:
<html>
<head>
<title>Contacting Worldpay, Please wait.......</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#000000" text="#CCCCCC">
<?php
$basketvalues = array_values($HTTP_POST_VARS);
$basketkeys = array_keys($HTTP_POST_VARS);
$totalitems=((count($basketkeys))-17)/11;
$instId = $basketvalues[array_search("instId", $basketkeys, true)];
$cartId = $basketvalues[array_search("cartId", $basketkeys, true)];
$cost = $basketvalues[array_search("cost", $basketkeys, true)];
$currency = $basketvalues[array_search("currency", $basketkeys, true)];
$desc = $basketvalues[array_search("desc", $basketkeys, true)];
$country = $basketvalues[array_search("country", $basketkeys, true)];
$name = $basketvalues[array_search("name", $basketkeys, true)];
$address = $basketvalues[array_search("address", $basketkeys, true)];
$postcode = $basketvalues[array_search("postcode", $basketkeys, true)];
$tel = $basketvalues[array_search("tel", $basketkeys, true)];
$email = $basketvalues[array_search("email", $basketkeys, true)];
?>
<form name='worldform1' method='post' action='https://select.worldpay.com/wcc/transaction'>
<input type="hidden" name="cartId" value="<?php echo $cartId ?>">
<input type="hidden" name="instId" value="<?php echo $instId ?>">
<input type="hidden" name="cost" value="<?php echo $cost ?>">
<input type="hidden" name="currency" value="<?php echo $currency ?>">
<input type="hidden" name="desc" value="<?php echo $desc ?>">
<input type="hidden" name="country" value="<?php echo $country ?>">
<input type="hidden" name="name" value="<?php echo $name ?>">
<input type="hidden" name="address" value="<?php echo $address ?>">
<input type="hidden" name="county" value="<?php echo $county ?>">
<input type="hidden" name="postcode" value="<?php echo $postcode ?>">
<input type="hidden" name="tel" value="<?php echo $tel ?>">
<input type="hidden" name="email" value="<?php echo $email ?>">
<input type="hidden" name="testMode" value="101">
</form>
<script language="Javascript">
document.worldform1.submit();
</script>
<font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="2">Contacting Worldpay</font><br>
<font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="2">Please Wait ....</font>
</body>
</html>
Please help me solve the problem!
Many thanks,
Janusz