October 20th, 2008, 03:45 PM
|
#11 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
|
UPDATE: I inserted an "on error resume next" statement within that loop and the cart page opened fine, but no items were inserted. Below is a snippet of the code: Code: '**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
on error resume next
end if
CartToCookie CCcart,"CharonCart"
CC_RedirectURL="/store/cart.asp"
Response.Redirect "/store/cart.asp"
end if |
| |
October 20th, 2008, 03:49 PM
|
#12 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
Don't use on error resume next unless you plan on catching and handling all errors. All "on error resume next" is usually used for is hiding crap error prone code.
Take it out and post the error. Also change the CartToCookie back to accepting and using two arguments
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
|
| |
October 20th, 2008, 03:53 PM
|
#13 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
|
UPDATE: I inserted an "on error resume next" statement within that loop and the cart page opened fine, but no items were inserted. Below is a snippet of the code in details.asp: Code: '**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
on error resume next
end if
CartToCookie CCcart,"CharonCart"
CC_RedirectURL="/store/cart.asp"
Response.Redirect "/store/cart.asp"
end if |
| |
October 20th, 2008, 03:55 PM
|
#14 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
| Quote: |
UPDATE: I inserted an "on error resume next" statement within that loop and the cart page opened fine, but no items were inserted. Below is a snippet of the code in details.asp:
| Please see my previous post... |
| |
October 20th, 2008, 04:05 PM
|
#15 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn 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 | I've changed CartToCookie back, please let me know if the following code is correct before I execute it: 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(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()
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
%> |
| |
October 20th, 2008, 04:12 PM
|
#16 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
| Code: 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 1) TAKE OUT "on error resume next". That is unless you goal is to write code that doesn't work.
2) You are passing the function thearray and then using CCcart in the function. CCcart is not in the functions scope. Use thearray. |
| |
October 20th, 2008, 04:28 PM
|
#17 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn
1) TAKE OUT "on error resume next". That is unless you goal is to write code that doesn't work.
2) You are passing the function thearray and then using CCcart in the function. CCcart is not in the functions scope. Use thearray. | I've changed the code as follows: Code: function CartToCookie(thearray,cookiename)
mystring=""
for j=0 to ubound(thearray,2)
if thearray(CC_ProductID,j) <> "" then
for i=0 to 9
mystring=mystring & thearray(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 and replaced CCart with thearray (I hope I understood that correctly) |
| |
October 20th, 2008, 04:44 PM
|
#18 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
|
I've also tried it this way: Code: function CartToCookie(thearray,cookiename)
mystring=""
for j=0 to ubound(thearray,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 Either way, I get the same error. The new error is: Error Type: Invalid procedure call or argument: 'UBound'
/store/inc_CharonCart.asp, line 23
Which is: for i=0 to ubound(CCcart,2)
Thanks so much for your help.
Last edited by xingxang : October 20th, 2008 at 05:11 PM.
|
| |
October 20th, 2008, 07:36 PM
|
#19 (permalink)
| | Real gangstas sip on Yacc
Join Date: Oct 2001 Location: Suckas-ville
Posts: 4,549
|
You still have problems with the CartToCookie function
function CartToCookie(thearray,cookiename)
mystring=""
for j=0 to ubound(thearray,2)
if CCcart(CC_ProductID,j) <> "" then //Either use thearray or CCcart, don't use both.
for i=0 to 9
mystring=mystring & CCcart(i,j) & "^" //Same thing here, use thearray
next
mystring=left(mystring,len(mystring)-1)
mystring=mystring & "|"
end if
next
mystring=left(mystring,len(mystring)-1)
Response.Cookies(cookiename)=mystring
end function
Change the top part back to
if Request.Cookies("CharonCart") = "" then
dim CCcart(9,50)
else
CCcart=CookieToCart("CharonCart")
end if
I didn't realize you were going to actually be looking at the uninitialized array.
Did you write this or did someone provide this for you? |
| |
October 20th, 2008, 08:03 PM
|
#20 (permalink)
| | Junior Member
Join Date: Oct 2008
Posts: 17
| Quote:
Originally Posted by jkrohn
I didn't realize you were going to actually be looking at the uninitialized array.
Did you write this or did someone provide this for you? | This was given to me to migrate over. As I said, I've researched and reverse-engineered other obstacles in migrating mssql to mysql, but this just stumped me. It worked on the other server, which was windows with native asp handling, but not in sun one asp.
But if it has programming errors in general, kinda makes me question if it worked on the other server at all.
The company says it was a web form that prompted for the customer's information, and that form was sent to them.
Trying the new code now... Thanks again for your help! |
| | |
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  | | | | | |