October 19th, 2008, 11:32 PM
|
#1 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
|
I'm trying to set up an ASP shopping cart. My code is as follows: Code: <%
CONST CC_ProductID = 0
CONST CC_Quantity = 1
CONST CC_Name = 2
CONST CC_Price = 3
CONST CC_UniqueKey = 4
CONST CC_Weight = 5
CONST CC_Color = 6
CONST CC_Size = 7
CONST CC_Skew = 8
if Request.Cookies("CharonCart") = "" then
dim CCcart(9,50)
else
CCcart=CookieToCart("CharonCart")
end if
CCcart_SubTotal=0
CCcart_numItems=0
CCcart_Shipping=0
CCcart_Discount=0
CCcart_SalesTax=0
isFound=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) <> "" then
isFound=true
CCcart_SubTotal=CCcart_SubTotal + (CCcart(CC_Quantity,i)*CCcart(CC_Price,i))
CCcart_numItems=CCcart_numItems + 1
end if
next
function CCcart_LineTotal
CCcart_LineTotal=CCcart(CC_Quantity,i)*CCcart(CC_Price,i)
end function
function CCcart_GrandTotal
CCcart_GrandTotal=CCcart_SubTotal + CCcart_Shipping + CCcart_SalesTax - CCcart_Discount
end function
function CartToCookie(thearray,cookiename)
on error resume next
mystring=""
for j=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,j) <> "" then
for i=0 to 9
mystring=mystring & CCcart(i,j) & "^"
next
mystring=left(mystring,len(mystring)-1)
mystring=mystring & "|"
end if
next
mystring=left(mystring,len(mystring)-1)
Response.Cookies(cookiename)=mystring
end function
function CookieToCart(cookiename)
dim myarray(9,50)
mystring=Request.Cookies(cookiename)
productarray=split(mystring,"|")
for j=0 to ubound(productarray)
itemarray=split(productarray(j),"^")
for i=0 to 9
if itemarray(i) <> "" then
myarray(i,j)=itemarray(i)
else
myarray(i,j)=null
end if
next
next
CookietoCart=myarray
end function
%> Executing the code in the browser gives me the following error: Code: The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
Please try the following:
* Click the Refresh button, or try again later.
* Open the website's home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Apache/1.3.37 (Unix) Sun-ONE-ASP/4.0.2 mod_jk/1.2.14 mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28
OpenSSL/0.9.7a PHP-CGI/0.1b
Technical Information (for support personnel)
* Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
/store/inc_CharonCart.asp, line 68
* Browser Type:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008091700
SUSE/3.0.3-1.1 Firefox/3.0.3
* Page:
GET /store/details.asp
* Time:
Sunday, October 19, 2008, 9:22:50 PM
* More information:
Sun ONE Active Server Pages Support Can you shed some light on what's going on? Thanks!
Last edited by xingxang : October 20th, 2008 at 01:23 PM.
|
| |
October 20th, 2008, 11:34 AM
|
#2 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Is the Sun ASP case sensitive (MS asp is not)
If so your problem could lie here
function CookieToCart(cookiename)
CookietoCart=myarray
Jkrohn
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
|
| |
October 20th, 2008, 12:07 PM
|
#3 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn Is the Sun ASP case sensitive (MS asp is not)
If so your problem could lie here
function CookieToCart(cookiename)
CookietoCart=myarray
Jkrohn | Great eye, changed it, still getting type mismatch on same line. |
| |
October 20th, 2008, 12:40 PM
|
#4 (permalink)
| | Member
Join Date: Jul 2008
Posts: 45
|
I don't know too much about asp, but in general programming... I think the problem lies with where you declared the function.
function CartToCookie(thearray,cookiename)
in most languages means that you have 2 variables. yet you only end up passing cookiename. What is thearray and why aren't you passing it to the function? |
| |
October 20th, 2008, 01:21 PM
|
#5 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by theGlitch I don't know too much about asp, but in general programming... I think the problem lies with where you declared the function.
function CartToCookie(thearray,cookiename)
in most languages means that you have 2 variables. yet you only end up passing cookiename. What is thearray and why aren't you passing it to the function? | I don't know much about asp, and it's been years since i've done any type of programming outside of routers and switches. I've been able to reverse engineer my way to migrating this site from SQL to MySql on Sun One, but now I'm in dire need of assistance when it comes to getting this shopping cart working.
Another interesting thing I've noticed, is once this error occurs, I can no longer check the details page on the products either. I have to clear the cookies and cache, close and reopen the browser, to be able to see the details again.
Last edited by xingxang : October 20th, 2008 at 01:26 PM.
|
| |
October 20th, 2008, 02:28 PM
|
#6 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
I would do the following.
When declaring CC, take out the size for the initial array declaration. When the array object is returned from the function it will make it the right size.
In CookieToCart why is the array statically sized to 9,50 when it clearly doesn't need to be? You can use ubound of your product array to set the size correctly at runtime. |
| |
October 20th, 2008, 02:49 PM
|
#7 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn I would do the following.
When declaring CC, take out the size for the initial array declaration. When the array object is returned from the function it will make it the right size.
In CookieToCart why is the array statically sized to 9,50 when it clearly doesn't need to be? You can use ubound of your product array to set the size correctly at runtime. | Thanks jkrohn. So removing all of the declarations (9,50) produces a type mismatch on line 23 - for i=0 to ubound(CCcart,2)
But by merely removing it from the declaration under CookieToCart(cookiename) and leaving it under the initial declaration resolves the issue of having to clear cookies and restart the browser in order to view the details! The revised code looks like this: Code: <%
CONST CC_ProductID = 0
CONST CC_Quantity = 1
CONST CC_Name = 2
CONST CC_Price = 3
CONST CC_UniqueKey = 4
CONST CC_Weight = 5
CONST CC_Color = 6
CONST CC_Size = 7
CONST CC_Skew = 8
if Request.Cookies("CharonCart") = "" then
dim CCcart(9,50)
else
CCcart=CookieToCart("CharonCart")
end if
CCcart_SubTotal=0
CCcart_numItems=0
CCcart_Shipping=0
CCcart_Discount=0
CCcart_SalesTax=0
isFound=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) <> "" then
isFound=true
CCcart_SubTotal=CCcart_SubTotal + (CCcart(CC_Quantity,i)*CCcart(CC_Price,i))
CCcart_numItems=CCcart_numItems + 1
end if
next
function CCcart_LineTotal
CCcart_LineTotal=CCcart(CC_Quantity,i)*CCcart(CC_Price,i)
end function
function CCcart_GrandTotal
CCcart_GrandTotal=CCcart_SubTotal + CCcart_Shipping + CCcart_SalesTax - CCcart_Discount
end function
function CartToCookie(cookiename)
on error resume next
mystring=""
for j=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,j) <> "" then
for i=0 to 9
mystring=mystring & CCcart(i,j) & "^"
next
mystring=left(mystring,len(mystring)-1)
mystring=mystring & "|"
end if
next
mystring=left(mystring,len(mystring)-1)
Response.Cookies(cookiename)=mystring
end function
function CookieToCart(cookiename)
dim myarray
mystring=Request.Cookies(cookiename)
productarray=split(mystring,"|")
for j=0 to ubound(productarray)
itemarray=split(productarray(j),"^")
for i=0 to 9
if itemarray(i) <> "" then
myarray(i,j)=itemarray(i)
else
myarray(i,j)=null
end if
next
next
CookieToCart=myarray
end function
%> Feels like progress... but I'm getting another error, this time on details.asp page. The new error is:
Error Type: Sun ONE ASP VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'CartToCookie'
/store/details.asp, line 269
Here is the details.asp page: Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="store/inc_CharonCart.asp" -->
<%
Dim rsMetaTags
Dim rsMetaTags_numRows
Dim dsn
dsn = "Driver={Mysql}; Server=localhost; Port=3306; Database=pvcspor1_pvcspor1; UID=pvcspor1_kim; PWD=Sugar1"
dim dbConn
set dbConn = server.createObject ("ADODB.connection")
dbconn.open dsn
Set rsMetaTags = Server.CreateObject("ADODB.Recordset")
rsMetaTags.ActiveConnection = dbconn
rsMetaTags.Source = "SELECT * FROM site_meta"
rsMetaTags.CursorType = 0
rsMetaTags.CursorLocation = 2
rsMetaTags.LockType = 1
rsMetaTags.Open()
rsMetaTags_numRows = 0
%>
<%
Dim rsProducts__MMColParam
rsProducts__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsProducts__MMColParam = Request.QueryString("productID")
End If
%>
<%
set rsProducts = Server.CreateObject("ADODB.Recordset")
rsProducts.ActiveConnection = dbconn
rsProducts.Source = "SELECT * FROM store_products WHERE site = 'yes' AND productID = " + Replace(rsProducts__MMColParam, "'", "''") + ""
rsProducts.CursorType = 0
rsProducts.CursorLocation = 2
rsProducts.LockType = 3
rsProducts.Open()
rsProducts_numRows = 0
%>
<%
Dim rsListCategories
Dim rsListCategories_numRows
Set rsListCategories = Server.CreateObject("ADODB.Recordset")
rsListCategories.ActiveConnection = dbconn
rsListCategories.Source = "SELECT * FROM store_categories ORDER BY title ASC"
rsListCategories.CursorType = 0
rsListCategories.CursorLocation = 2
rsListCategories.LockType = 1
rsListCategories.Open()
rsListCategories_numRows = 0
%>
<%
Dim rsSpecials
Dim rsSpecials_numRows
Set rsSpecials = Server.CreateObject("ADODB.Recordset")
rsSpecials.ActiveConnection = dbconn
rsSpecials.Source = "SELECT store_products.productID, store_products.categoryID, store_products.name, store_products.item_skew, store_photos.photoID, store_photos.photo FROM store_products, store_photos WHERE special = 'yes' AND site = 'yes' AND store_products.productID = store_photos.productID ORDER BY categoryID ASC"
rsSpecials.CursorType = 0
rsSpecials.CursorLocation = 2
rsSpecials.LockType = 1
rsSpecials.Open()
rsSpecials_numRows = 0
%>
<%
Dim rsCategory__MMColParam
rsCategory__MMColParam = "1"
If (Request.QueryString("categoryID") <> "") Then
rsCategory__MMColParam = Request.QueryString("categoryID")
End If
%>
<%
Dim rsCategory
Dim rsCategory_numRows
Set rsCategory = Server.CreateObject("ADODB.Recordset")
rsCategory.ActiveConnection = dbconn
rsCategory.Source = "SELECT * FROM store_categories WHERE categoryID = " + Replace(rsCategory__MMColParam, "'", "''") + ""
rsCategory.CursorType = 0
rsCategory.CursorLocation = 2
rsCategory.LockType = 1
rsCategory.Open()
rsCategory_numRows = 0
%>
<%
Dim rsOptionColor__MMColParam
rsOptionColor__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsOptionColor__MMColParam = Request.QueryString("productID")
End If
%>
<%
Dim rsOptionColor
Dim rsOptionColor_numRows
Set rsOptionColor = Server.CreateObject("ADODB.Recordset")
rsOptionColor.ActiveConnection = dbconn
rsOptionColor.Source = "SELECT * FROM store_options_color WHERE productID = " + Replace(rsOptionColor__MMColParam, "'", "''") + ""
rsOptionColor.CursorType = 0
rsOptionColor.CursorLocation = 2
rsOptionColor.LockType = 1
rsOptionColor.Open()
rsOptionColor_numRows = 0
%>
<%
Dim rsOptionSize__MMColParam
rsOptionSize__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsOptionSize__MMColParam = Request.QueryString("productID")
End If
%>
<%
Dim rsOptionSize
Dim rsOptionSize_numRows
Set rsOptionSize = Server.CreateObject("ADODB.Recordset")
rsOptionSize.ActiveConnection = dbconn
rsOptionSize.Source = "SELECT * FROM store_options_size WHERE productID = " + Replace(rsOptionSize__MMColParam, "'", "''") + ""
rsOptionSize.CursorType = 0
rsOptionSize.CursorLocation = 2
rsOptionSize.LockType = 1
rsOptionSize.Open()
rsOptionSize_numRows = 0
%>
<%
Dim rsPhotos__MMColParam
rsPhotos__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsPhotos__MMColParam = Request.QueryString("productID")
End If
%>
<%
Dim rsPhotos
Dim rsPhotos_numRows
Set rsPhotos = Server.CreateObject("ADODB.Recordset")
rsPhotos.ActiveConnection = dbconn
rsPhotos.Source = "SELECT * FROM store_photos WHERE productID = " + Replace(rsPhotos__MMColParam, "'", "''") + " ORDER BY photoID ASC"
rsPhotos.CursorType = 0
rsPhotos.CursorLocation = 2
rsPhotos.LockType = 1
rsPhotos.Open()
rsPhotos_numRows = 0
%>
<%
Dim rsDisplayPricing__MMColParam
rsDisplayPricing__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsDisplayPricing__MMColParam = Request.QueryString("productID")
End If
%>
<%
Dim rsDisplayPricing
Dim rsDisplayPricing_numRows
Set rsDisplayPricing = Server.CreateObject("ADODB.Recordset")
rsDisplayPricing.ActiveConnection = dbconn
rsDisplayPricing.Source = "SELECT * FROM store_prices WHERE productID = " + Replace(rsDisplayPricing__MMColParam, "'", "''") + " ORDER BY itemPrice ASC"
rsDisplayPricing.CursorType = 0
rsDisplayPricing.CursorLocation = 2
rsDisplayPricing.LockType = 1
rsDisplayPricing.Open()
rsDisplayPricing_numRows = 0
%>
<%
Dim rsChoosePricing__MMColParam
rsChoosePricing__MMColParam = "1"
If (Request.QueryString("productID") <> "") Then
rsChoosePricing__MMColParam = Request.QueryString("productID")
End If
%>
<%
Dim rsChoosePricing
Dim rsChoosePricing_numRows
Set rsChoosePricing = Server.CreateObject("ADODB.Recordset")
rsChoosePricing.ActiveConnection = dbconn
rsChoosePricing.Source = "SELECT * FROM store_prices WHERE productID = " + Replace(rsChoosePricing__MMColParam, "'", "''") + " ORDER BY itemPrice ASC"
rsChoosePricing.CursorType = 0
rsChoosePricing.CursorLocation = 2
rsChoosePricing.LockType = 1
rsChoosePricing.Open()
rsChoosePricing_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsListCategories_numRows = rsListCategories_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = -1
Repeat2__index = 0
rsDisplayPricing_numRows = rsDisplayPricing_numRows + Repeat2__numRows
%>
<%
'**Charon Cart**
'**Add to cart using a Form**
'
FormAction=Request.ServerVariables("SCRIPT_NAME")
If FormAction <> "" Then
Dim rsCalulatePricing__MMColParam
rsCalulatePricing__MMColParam = "1"
If (Request("priceID") <> "") Then
rsCalulatePricing__MMColParam = Request("priceID")
End If
Dim rsCalulatePricing
Dim rsCalulatePricing_numRows
Set rsCalulatePricing = Server.CreateObject("ADODB.Recordset")
rsCalulatePricing.ActiveConnection = dbconn
rsCalulatePricing.Source = "SELECT * FROM store_prices WHERE priceID = " + Replace(rsCalulatePricing__MMColParam, "'", "''") + ""
rsCalulatePricing.CursorType = 0
rsCalulatePricing.CursorLocation = 2
rsCalulatePricing.LockType = 1
rsCalulatePricing.Open()
rsCalulatePricing_numRows = 0
End If
if Request.Form <> "" then FormAction=FormAction & "?" & Request.Form
if Request.QueryString <> "" then FormAction=FormAction & "?" & Request.QueryString
if Request("Charon_Cart") <> "" then
Randomize Timer
isFound=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) = cstr(Request("productID")) and CCcart(CC_Weight,i)=Request("productWeight") and CCcart(CC_Color,i)=Request("itemColor") and CCcart(CC_Size,i)=Request("productSize") and CCcart(CC_Skew,i)=Request("item_skew") then
CCcart(CC_Quantity,i) = CCcart(CC_Quantity,i) + 1
isFound=true
exit for
end if
next
if not isFound then
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) = "" then
CCcart(CC_ProductID,i)=Request("productID")
CCcart(CC_Quantity,i)=("1")
CCcart(CC_Name,i)=Request("productName")
CCcart(CC_Price,i)=rsCalulatePricing.Fields.Item("itemPrice").Value
CCcart(CC_Weight,i)=rsCalulatePricing.Fields.Item("itemWeight").Value
CCcart(CC_Color,i)=Request("itemColor")
CCcart(CC_Size,i)=rsCalulatePricing.Fields.Item("itemSize").Value
CCcart(CC_Skew,i)=Request("item_skew")
CCcart(CC_UniqueKey,i)=int(rnd*9999999)+10000000
exit for
end if
next
end if
CartToCookie CCcart,"CharonCart"
CC_RedirectURL="/store/cart.asp"
Response.Redirect "/store/cart.asp"
end if
%>
<html><!-- InstanceBegin template="/Templates/pvcsports_main.dwt.asp" codeOutsideHTMLIsLocked="false" -->
<head>
<title><%=(rsMetaTags.Fields.Item("title").Value)%></title>
<!-- InstanceBeginEditable name="head" -->
<meta name="description" content="<%=(rsMetaTags.Fields.Item("description").Value)%>">
<meta name="keywords" content="<%=(rsMetaTags.Fields.Item("keywords").Value)%>">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<!-- InstanceEndEditable --><br>
<meta name="description" content="<%=(rsMetaTags.Fields.Item("description").Value)%>">
<meta name="keywords" content="<%=(rsMetaTags.Fields.Item("keywords").Value)%>">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<SCRIPT>if(navigator.userAgent.indexOf("MSIE") != -1)
document.writeln ('<bgsound src="/audio/swing.wav">');else
document.writeln ('<embed src="swing.wav" autostart=true hidden=true>');</SCRIPT>
<body>
<div align="center">
<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">
<!--#include virtual="/includes/main/header.asp" -->
</div>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#F7EEDB"><!-- InstanceBeginEditable name="main" -->
<div align="center">
<table width="100%" border="0" align="right">
<tr>
<td colspan="3" valign="top"> </td>
</tr>
<tr>
<td width="166%" colspan="3" valign="top"><div align="right">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<form name="form1" method="get" action="/store/list.asp">
<td width="56%" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif"><font color="#000066" size="2"><em><strong><%=(rsProducts.Fields.Item("name").Value)%></strong></em></font></font></td>
</form>
<td width="44%" valign="top"><div align="right">
<% If Not rsProducts.EOF Or Not rsProducts.BOF Then %>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="viewcart" type="button" id="viewcart2" onClick="MM_goToURL('parent','/store/cart.asp');return document.MM_returnValue" value="View Cart">
</font><font color="#FFFFFF" size="2" face="Comic Sans MS">
<input name="checkout" type="button" id="checkout3" onClick="MM_goToURL('parent','/store/customers/verify_user.asp');return document.MM_returnValue" value="Check Out">
</font>
<% End If ' end Not rsProducts.EOF Or NOT rsProducts.BOF %>
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="3" valign="top"><div align="center"> <br>
<table>
<%
startrw = 0
endrw = HLooper1__index
numberColumns = 2
numrows = -1
while((numrows <> 0) AND (Not rsPhotos.EOF))
startrw = endrw + 1
endrw = endrw + numberColumns
%>
<tr align="center" valign="top">
<%
While ((startrw <= endrw) AND (Not rsPhotos.EOF))
%>
<td> <img src="http://pvcsports.com/images/store/products/<%=(rsPhotos.Fields.Item("photo").Value)%>" border="1"> </td>
<%
startrw = startrw + 1
rsPhotos.MoveNext()
Wend
%>
</tr>
<%
numrows=numrows-1
Wend
%>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="3" valign="top"> </td>
</tr>
<tr>
<td colspan="3" valign="top"><div align="right">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2">
<%
Dim MyText
MyText = ((rsProducts.Fields.Item("description_main").Value))
MyText =Replace(MyText,vbcrlf,"<br>")
Response.write MyText
%>
</font></font></td>
</tr>
<tr>
<td><form action="<%=FormAction%>" method="get" name="frmAddCart" id="frmAddCart">
<div align="right"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font color="#333399" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="productID" type="hidden" id="productID" value="<%=(rsProducts.Fields.Item("productID").Value)%>">
<input name="item_skew" type="hidden" id="item_skew" value="<%=(rsProducts.Fields.Item("item_skew").Value)%>">
<input name="productName" type="hidden" id="productName" value="<%=(rsProducts.Fields.Item("name").Value)%>">
</font></a></font></a></font><font color="#333399" size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></a><br>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="51%" valign="top"><div align="right"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<%If rsProducts.Fields.item("option_color").Value = "yes" Then%>
</font></a></font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Select
Color:</font></a>
<select name="itemColor" id="select">
<%
While (NOT rsOptionColor.EOF)
%>
<option value="<%=(rsOptionColor.Fields.Item("itemColor").Value)%>"><%=(rsOptionColor.Fields.Item("itemColor").Value)%></option>
<%
rsOptionColor.MoveNext()
Wend
If (rsOptionColor.CursorType > 0) Then
rsOptionColor.MoveFirst
Else
rsOptionColor.Requery
End If
%>
</select>
<BR>
<%End If%>
<a><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Select
Size: <strong>
<select name="priceID" id="select2">
<%
While (NOT rsChoosePricing.EOF)
%>
<option value="<%=(rsChoosePricing.Fields.Item("priceID").Value)%>"><%=(rsChoosePricing.Fields.Item("itemSize").Value)%> - <%=FormatCurrency(rsChoosePricing.Fields.Item("itemPrice").Value)%></option>
<%
rsChoosePricing.MoveNext()
Wend
If (rsChoosePricing.CursorType > 0) Then
rsChoosePricing.MoveFirst
Else
rsChoosePricing.Requery
End If
%>
</select>
<BR>
</strong></font></a> </font></a> <font size="1" face="Arial, Helvetica, sans-serif"><strong><br>
</strong><%=(rsProducts.Fields.Item("item_skew").Value)%></font>
<input name="Submit" type="submit" value="Add To Cart">
</div>
</td>
</tr>
</table>
<a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a></a></font></a></font></a></font></a></font><font color="#333399" size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></a></font></a></font></a></div>
</td>
</tr>
</table>
</div>
<input type="hidden" name="Charon_Cart" value="1">
</form>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><!--#include virtual="/includes/main/footer.asp" -->
</td>
</tr>
</table>
</div>
</body>
<!-- InstanceEnd --></html>
<%
rsListCategories.Close()
Set rsListCategories = Nothing
%>
<%
rsSpecials.Close()
Set rsSpecials = Nothing
%>
<%
rsProducts.Close()
Set rsProducts = Nothing
%>
<%
rsCategory.Close()
Set rsCategory = Nothing
%>
<%
rsOptionColor.Close()
Set rsOptionColor = Nothing
%>
<%
rsOptionSize.Close()
Set rsOptionSize = Nothing
%>
<%
rsPhotos.Close()
Set rsPhotos = Nothing
%>
<%
rsDisplayPricing.Close()
Set rsDisplayPricing = Nothing
%>
<%
rsChoosePricing.Close()
Set rsChoosePricing = Nothing
%>
<%
rsCalulatePricing.Close()
Set rsCalulatePricing = Nothing
%>
<%
rsMetaTags.Close()
Set rsMetaTags = Nothing
%> Line 269 is an end if statement, and has been bolded in the code.
At least now, it looks like the session is being maintained properly, so it feels like progress. Thanks jkrohn!
Last edited by xingxang : October 20th, 2008 at 03:16 PM.
|
| |
October 20th, 2008, 03:06 PM
|
#8 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Try changing
dim CCcart to dim CCcart() to give it an initial type as array. |
| |
October 20th, 2008, 03:38 PM
|
#9 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn Try changing
dim CCcart to dim CCcart() to give it an initial type as array. | Ok, the new code looks like this: Code: <%
CONST CC_ProductID = 0
CONST CC_Quantity = 1
CONST CC_Name = 2
CONST CC_Price = 3
CONST CC_UniqueKey = 4
CONST CC_Weight = 5
CONST CC_Color = 6
CONST CC_Size = 7
CONST CC_Skew = 8
if Request.Cookies("CharonCart") = "" then
dim CCcart()
else
CCcart=CookieToCart("CharonCart")
end if
CCcart_SubTotal=0
CCcart_numItems=0
CCcart_Shipping=0
CCcart_Discount=0
CCcart_SalesTax=0
isFound=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) <> "" then
isFound=true
CCcart_SubTotal=CCcart_SubTotal + (CCcart(CC_Quantity,i)*CCcart(CC_Price,i))
CCcart_numItems=CCcart_numItems + 1
end if
next
function CCcart_LineTotal
CCcart_LineTotal=CCcart(CC_Quantity,i)*CCcart(CC_Price,i)
end function
function CCcart_GrandTotal
CCcart_GrandTotal=CCcart_SubTotal + CCcart_Shipping + CCcart_SalesTax - CCcart_Discount
end function
function CartToCookie(cookiename)
on error resume next
mystring=""
for j=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,j) <> "" then
for i=0 to 9
mystring=mystring & CCcart(i,j) & "^"
next
mystring=left(mystring,len(mystring)-1)
mystring=mystring & "|"
end if
next
mystring=left(mystring,len(mystring)-1)
Response.Cookies(cookiename)=mystring
end function
function CookieToCart(cookiename)
dim myarray()
mystring=Request.Cookies(cookiename)
productarray=split(mystring,"|")
for j=0 to ubound(productarray)
itemarray=split(productarray(j),"^")
for i=0 to 9
if itemarray(i) <> "" then
myarray(i,j)=itemarray(i)
else
myarray(i,j)=null
end if
next
next
CookieToCart=myarray
end function
%> Clicking the "add to cart" gives me:
Error Type: Sun ONE ASP VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'CartToCookie'
/store/details.asp, line 269
in which line 269 is an end if statement. |
| |
October 20th, 2008, 03:43 PM
|
#10 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Why did you change CartToCookie to only accept one argument.....?
CartToCookie has no access CCcart unless you pass it as a paramater like you initially posted with the myarray argument then using that as the variable.
I imagine the call in details.asp is using two arguments.
Jkrohn |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |