Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data -> Structure

Status
Not open for further replies.

Sarky78

Programmer
Joined
Oct 19, 2000
Messages
878
Location
GB
Hi,

I have a load of order data that i want to store in a session until the order has been submitted. Once this order has been submitted the data will be written to the database.

What I have at the moment is a load of session variables defining this that and the other. What i was thinking of doing os to create a session variable that is a structure and then add this order data into that.

this is what i have at the moment:

<CFLOOP QUERY=&quot;getOrder&quot;>
<CFLOCK TIMEOUT=&quot;10&quot; THROWONTIMEOUT=&quot;No&quot; NAME=&quot;#Session.SessionID#&quot; TYPE=&quot;Exclusive&quot;>
<CFIF isDefined('Session.Cart') IS &quot;No&quot;>
<CFSET Session.Cart = StructNew()> </CFIF>

<CFSCRIPT>
StructInsert(Session.Cart,&quot;ProductCode&quot;,&quot;getOrder.ProductCode&quot;);
</CFSCRIPT>
</CFLOOP>

When i run this code i get:

Cannot insert item with key ProductCode...possibly key already exists

I have got 8 records that are returned by the database that i want to put into this structure. Do i have to have a new structure for each order row that is returned ?

I have used the CFSET method and did not get this error message but then that only inserted one row of data into the structure.

I have seen a structure used before in this way but can't currently find the code that was used to do this.

does anyone have any ideas on how i can have multiple enteries in one structure
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top