Skip to main content
WebolutionDesigns
Known Participant
October 11, 2010
Question

element at position 2 cannot be found

  • October 11, 2010
  • 2 replies
  • 4539 views

I have been beating my brains out trying to figure this out. If any of you have thoughts, I would love to hear them. I have a cflocation to redirect to PayPal as follows...

<cflocation url="https://www.paypal.com/cgi-bin/websrc?tax_cart=#WA_eCart_FormatNumber(WA_eCart_GetTax(whitcart), false, 2)#&no_note=0&no_shipping=1&return=http://xxxxxxxx.com/paypalsuccess.cfm&cmd=_cart&upload=1&currency_code=USD&address_override=0&firstname=#IIf(isDefined('session.firstname'),'session.firstname',DE(''))#&lastname=#IIf(isDefined('session.lastname'),'session.lastname',DE(''))#&street1=#IIf(isDefined('session.street1'),'session.street1',DE(''))#&street2=#IIf(isDefined('session.street2'),'session.street2',DE(''))#&city=#IIf(isDefined('session.city'),'session.city',DE(''))#&state_province=#IIf(isDefined('session.state_province'),'session.state_province',DE(''))#&postcode=#IIf(isDefined('session.postcode'),'session.postcode',DE(''))#&country=#IIf(isDefined('session.country'),'session.country',DE(''))#&email=#IIf(isDefined('session.email'),'session.email',DE(''))#&phone=#IIf(isDefined('session.phone'),'session.phone',DE(''))#&ordernumber=#IIf(isDefined('session.ordernumber'),'session.ordernumber',DE(''))#&handling_cart=#WA_eCart_FormatNumber(WA_eCart_GetShipping(whitcart)+WA_eCart_GetCharges(whitcart), false, 2)#&

<cfoutput>

    <CFLOOP FROM='1' TO='#ArrayLen(session.whitcart_items)#' INDEX='i'>

        <CFLOOP COLLECTION='#session.whitcart_items#' ITEM='y'>

            <CFIF StructKeyExists(session.whitcart_items, y)>

                #y#=#session.whitcart_items#&

            </CFIF>

        </CFLOOP>

    </CFLOOP>

</cfoutput>

business=xxxxxx@xxxxxxx.com" />

When I run this, it comes back with element at position 2 cannot be found. The probem is that my array only has one item in it. I dumped it to the screen and see this...

Price=0.01 TotalPrice=0.01 Name=The_Day_After_His_Birth.pdf Weight=0 Description=The Day After His Birth FullDetails=1 The_Day_After_His_Birth.pdf (2) ID=2 TotalWeight=0 Quantity=1

So I am struggling as to what is occurring.

Thoughts?

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
October 12, 2010

Are you sure the error is occurring where you think it is? To find out, test by replacing the line

<CFLOOP FROM='1' TO='#ArrayLen(session.whitcart_items)#' INDEX='i'>

with

<CFLOOP FROM='1' TO='1' INDEX='i'>

Do you get the same error message? If so, does Coldfusion refer you to a line number where the error occurs?

WebolutionDesigns
Known Participant
October 12, 2010

Thanks for the input. I decided to go in a different direction by utilizing a cfc and calling the functions using ajax.

Inspiring
October 12, 2010

Is your array 1D or 2D?

WebolutionDesigns
Known Participant
October 12, 2010

It is an array with a struct inside it. Here is a copy...

array

1
struct
DescriptionThe Day After His Birth
FullDetails1 The_Day_After_His_Birth.pdf (2)
ID2
NameThe_Day_After_His_Birth.pdf
Price0.01
Quantity1
TotalPrice0.01
TotalWeight0
Weight0

Inspiring
October 12, 2010

So in other words, it's a 1D array.  That means this line will never work:

#y#=#session.whitcart_items#