ndcollins
asked on
Coldfusion MySQL INSERT Problem
OK, I'm using the following code to process a form and insert the form contents into my MySQL database. I've run the SQL code seperately by manually putting in values and it runs just fine. Also, I ran a CFOUTPUT to make sure the values were being passed and they all were. For some reason, the transaction is failing though and the insert is not happening. The ContribNum value is blank because it's an autoincrement field in the database. Anyone got any ideas what I'm missing?
<cftransaction action="begin">
<cftry>
<cfquery name="qAddContrib" datasource="CDS_App_Giving Beta">
INSERT INTO givingbeta.names
(Address1,
Address2,
City,
Country,
EnvNum,
FirstName,
LastName,
SSN,
State,
Zip,
ContribNum,
UUID)
VALUES('#FORM.Address1#',
'#FORM.Address2#',
'#FORM.City#',
'#FORM.Country#',
'#FORM.EnvNum#',
'#FORM.FirstName#',
'#FORM.LastName#',
'#FORM.SSN#',
'#FORM.State#',
'#FORM.Zip#',
'',
'#CreateUUID()#'
)
</cfquery>
<cfset confirmadd = "yes">
<cftransaction action="COMMIT" />
<cfcatch type="DATABASE">
<cftransaction action="ROLLBACK" />
<cfset confirmadd = "no">
</cfcatch>
</cftry>
</cftransaction>
<cflocation url="contrib_list.cfm?conf irmadd=#co nfirmadd#" >
<cftransaction action="begin">
<cftry>
<cfquery name="qAddContrib" datasource="CDS_App_Giving
INSERT INTO givingbeta.names
(Address1,
Address2,
City,
Country,
EnvNum,
FirstName,
LastName,
SSN,
State,
Zip,
ContribNum,
UUID)
VALUES('#FORM.Address1#',
'#FORM.Address2#',
'#FORM.City#',
'#FORM.Country#',
'#FORM.EnvNum#',
'#FORM.FirstName#',
'#FORM.LastName#',
'#FORM.SSN#',
'#FORM.State#',
'#FORM.Zip#',
'',
'#CreateUUID()#'
)
</cfquery>
<cfset confirmadd = "yes">
<cftransaction action="COMMIT" />
<cfcatch type="DATABASE">
<cftransaction action="ROLLBACK" />
<cfset confirmadd = "no">
</cfcatch>
</cftry>
</cftransaction>
<cflocation url="contrib_list.cfm?conf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your comment did make me think of a couple other things to try through, and I've now got it working. Thanks!
ASKER