Carpool_location is probably a string data type in the database? Strings need
to be surrounded by single quotes.
I would do like Leigh suggested. It is best practice to use <cfqueryparam>.
You may need to adjust the cfsqltype to what you database fields are. I
guessed numeric and varchar.
<cfquery datasource="mydb" name="getFirstAndLast">
SELECT FirstName, LastName
FROM contacts
WHERE contactid = <cfqueryparam cfsqltype="cf_sql_numeric"
value="#FORM.player#">
</cfquery>
<cfquery datasource="mydb" name="insertPlayer">
INSERT player (contactID, player, carpool_location)
VALUES (<cfqueryparam cfsqltype="cf_sql_numeric" value="#FORM.player#">,
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#getFirstAndLast.FirstName# #getFirstAndLast.LastName#">,
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#FORM.carpool_location#">)
</cfquery>
-----Original Message-----
From: Barry Mcconaghey [mailto:[email protected]]
Sent: Thursday, February 11, 2010 2:43 PM
To: cf-talk
Subject: Re: cfinsert multiple records into DB
I'm getting an error message.
I added this inside my CFFORM
<input type="text" size="40" name="carpool_location" />
Action page:
<cfquery datasource="mydb" name="getFirstAndLast">
SELECT FirstName, LastName
FROM contacts
WHERE contactid = #FORM.player#
</cfquery>
<cfquery datasource="mydb" name="insertPlayer">
INSERT player (contactID, player, carpool_location)
VALUES (#FORM.player#,'#getFirstAndLast.FirstName# #getFirstAndLast.LastName#',
#FORM.carpool_location#)
</cfquery>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330616
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4