Copy link to clipboard
Copied
Hi,
I have a multi step form which stores each form variable into a session. At the end of the form I am trying to loop through the session variables and insert the values into a database but I keep getting cfml structure referenced as part of anexpression errors.
Here is my session code (this is stored in application.CFC:
<cfset SESSION.FormData = structNew() />
On the last step of the form, here is my loop:
<!--- lets get the colums from the quote table --->
<cfquery name="selectColumns" datasource="#request.dsn#">
SHOW COLUMNS
FROM INSURANCE_QUOTES
</cfquery>
<!---and lets enter the quote details by looping over the columns--->
<cfquery name="quoteUpdate" datasource="#request.dsn#">
UPDATE INSURANCE_QUOTES
SET HANDLER_ID='#session.userID#',
SCHEME_ID = '#form.insurance_scheme#',
<cfoutput query="selectColumns">
<cfif isdefined("REQUEST.FormData")>
<cfswitch expression="#left(type,3)#">
<cfcase value="dat">
<cf_dateasdata
DateType="#type#"
DateField="#REQUEST.FormData[field]#"
/>
#field# = #ThisDate#,
</cfcase>
<cfcase value="dec,int">
<cfif REQUEST.FormData[field] eq ''>
#field# = null,
<cfelse>
<cfloop from="1" to="#len(variables.numericExclusions)#" index="thisExclusion">
<cfset REQUEST.FormData[field] = replace(REQUEST.FormData[field],mid(variables.numericExclusions,thisExclusion,1),"","All") />
</cfloop>
#field# = '#REQUEST.FormData[field]#',
</cfif>
</cfcase>
<cfcase value="tex,var">
#field# = <cfqueryparam value="#REQUEST.FormData[field]#" cfsqltype="cf_sql_longvarchar" />,
</cfcase>
<cfdefaultcase>
#field# = '#REQUEST.FormData[field]#',
</cfdefaultcase>
</cfswitch>
</cfif>
</cfoutput>
DATE_CREATED = #now()#,
QUOTE_EXPIRY = #quoteExpiry#,
USER_LAST_UPDATED = '#session.userID#'
WHERE QUOTE_ID = '#thisQuote#'
</cfquery>
Can anyone see any problems with my syntax?
I'd appreciate any support
Copy link to clipboard
Copied
What are you looping through? Is it session.FormData or Request.FormData?
What happens when you run the code?
Copy link to clipboard
Copied
Hi,
I have tried using session.formdata but to output data on the screen request.formdata seems to work better.
I get element QUOTE_ID is not referenced as part of an expression.
Stepping through the code, it errors on each field.
Copy link to clipboard
Copied
Do you have debugging turned on? What sql is being sent to the database?