home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2824
Discussions: 188,381, Posts: 2,243,469, Members: 232,609
Old 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

xingxang is offline   Reply With Quote
Old October 20th, 2008, 03:49 PM     #12 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,549
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
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.

jkrohn is offline   Reply With Quote
Old 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

xingxang is offline   Reply With Quote
Old October 20th, 2008, 03:55 PM     #14 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,549
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
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...
jkrohn is offline   Reply With Quote
Old October 20th, 2008, 04:05 PM     #15 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 17
Quote:
Originally Posted by jkrohn View Post
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
%>
xingxang is offline   Reply With Quote
Old October 20th, 2008, 04:12 PM     #16 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,549
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
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.
jkrohn is offline   Reply With Quote
Old October 20th, 2008, 04:28 PM     #17 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 17
Quote:
Originally Posted by jkrohn View Post

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)
xingxang is offline   Reply With Quote
Old 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.
xingxang is offline   Reply With Quote
Old October 20th, 2008, 07:36 PM     #19 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,549
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
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?
jkrohn is offline   Reply With Quote
Old October 20th, 2008, 08:03 PM     #20 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 17
Quote:
Originally Posted by jkrohn View Post

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!
xingxang is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Type I & Type II Compact Flash - difference? MTAtech Multimedia and Audio 0 July 3rd, 2004 08:48 AM
What type of entertainment are you into? Dj-Icer General Gaming Discussion 12 October 29th, 2003 11:12 AM
What type are you? Warthog IMO Community 23 May 26th, 2003 09:11 AM
How come when I type... DavidES Technical Support 3 November 17th, 2002 12:59 PM
What type are you? ocit IMO Community 28 March 30th, 2002 11:30 PM

Most Active Discussions
Is It Just Me? (2886)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
Folderchat Weekday thread (439)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Help with an Ati Radeon HD 4850 512.. (25)
Recent Discussions
RCA 52Inch HDTV wont turn on (1)
Building a gaming computer advi.. (1)
Best digital camera for under 2.. (14)
Help with an Ati Radeon HD 4850.. (25)
Install Problem for Windows Def.. (0)
New Build ( Finally ) (1)
dual monitors wont boot (0)
Folderchat Weekday thread (439)
MSN Hotmail Down??? (7)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 09:00 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28