Welp, I'm about ready to hang up the keyboard with this thing. I've
built a small shopping cart app. It's working perfectly on my
development machine. Woohoo.
So I move it to production to get it started. First problem -- can't
lock scopes. I don't know what version they're using of CF (I thought it
was 4.5.2 like my development machine, guess I was wrong), or if this is
a limitation of being on a shared server, but I fixed it by switching
them to name="#session.sessionid#". First hurdle done.
I've added a couple of items to my cart and I'd like to proceed to
checkout. The cart is a structure, using the name of the product as its
key, and an array containing things like productID, price, and quantity
as the value. Again working perfectly on development, however there is
now ONE item in the product list that throws an error when I add it to
the cart. I'm overlooking this for the time being since all the other
materials can be added to the cart.
Now the final slap in the face. I go to checkout with valid items and
update the quantity. The code which does this is pretty simple:
-------------
<cfif isdefined("form.update")>
<!--- Make sure that the user clicked the "update quantities"
button --->
<cfloop collection="#form#" item="fld">
<!--- Loop through the elements in the form that was posted --->
<cfif IsNumeric(form[fld]) IS "Yes">
<!--- Form elements are named with the key to each structure. The loop
is necessary because the form also passes the submitted button along
with the rest of the elements. This loop ensures that we don't try to
find an entry in the structure with an invalid key --->
<cflock name="#session.sessionid#" type="exclusive" timeout="5">
<cfif StructKeyExists(session.cart, "#fld#")>
<cf_addItem
id="#session.cart[fld][1]#"
name="#session.cart[fld][2]#"
price="#session.cart[fld][3]#"
quantity="#form[fld]#">
<!--- Update the quantities for each element in the structure. Even
though not all the elements need updating, this prevents us from having
to do an extra check to see if the new quantity is different from the
previous --->
</cfif>
</cflock>
</cfif>
</cfloop>
</cfif>
-------------
The error I get when trying to submit the form is:
Error resolving parameter FORM
ColdFusion was unable to determine the value of the parameter. This
problem is very likely due to the fact that either:
1. You have misspelled the parameter name, or
2. You have not specified a QUERY attribute for a CFOUTPUT, CFMAIL, or
CFTABLE tag.
The error occurred while evaluating the expression:
"#form#"
The line number quoted points to <cfloop collection="#form#"
item="fld">. Now, I'm at a total loss as to what is causing this to
happen. Any suggestions before I throw my monitor through a wall?
thanks for your help,
- seriously frustrated fellow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists