If you add the values to a struct you have to refer to the struct in the
cfquery tag:

<CFQUERY DATASOURCE="LIGHT2">
INSERT INTO TEMP_SHOPPING_CART
(NAME,ADDRESS,blahblah...)
VALUES
('#SHOPPING.NAME#','#SHOPPING.ADDRESS#',blahblah...)
</CFQUERY>

Also, the standard unsolicited advice - always use CFQUERYPARAM when doing
any query, including inserts:

<CFQUERY DATASOURCE="LIGHT2">
INSERT INTO TEMP_SHOPPING_CART
(NAME,ADDRESS,blahblah...)
VALUES
(<cfqueryparam cfsqltype="cf_sql_varchar" value="#SHOPPING.NAME#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#SHOPPING.ADDRESS#">,
blahblah...)
</CFQUERY>

-----Original Message-----
From: Ernest Douglas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 3 May 2005 11:53 
To: CF-Newbie
Subject: ColdFusion and Database

I am using ColdFusion to implement a shopping cart. I have a form to collect
name and address and the next page places these values in the database.
(rather, is SUPPOSED to place them in a database)Below is the code for
getting data from the form and placing data into the database.
Thank you in advance for any help!

<CFOUTPUT>

        <CFSET SHOPPING=STRUCTNEW()>
        <CFSET SHOPPING.NAME=#FORM.NAME#>
        <CFSET SHOPPING.ADDRESS=#FORM.ADDRESS#>
        <CFSET SHOPPING.CITY=#FORM.CITY#>
        <CFSET SHOPPING.STATE=#FORM.STATE#>
        <CFSET SHOPPING.ZIP=#FORM.ZIP#>
        <CFSET SHOPPING.HOME_PHONE=#FORM.HOME_PHONE#>
        <CFSET SHOPPING.EMAIL=#FORM.EMAIL#>

                
<CFIF LEN(#FORM.BPHONE#) EQ 0>
        <CFSET BPHONE = "Not Applicable">
<CFELSE>
        <CFSET BPHONE = "#FORM.BPHONE#">        
</cfif>         
                <CFQUERY DATASOURCE="LIGHT2">
                        INSERT INTO TEMP_SHOPPING_CART
 
(NAME,ADDRESS,CITY,STATE,ZIP,HOME_PHONE,BPHONE,EMAIL)
                        VALUES
 
('#NAME#','#ADDRESS#','#CITY#','#STATE#','#ZIP#','#HOME_PHONE#','#BPHONE#','
#EMAIL#')
                </CFQUERY>

</CFOUTPUT>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:866
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to