Link to home
Start Free TrialLog in
Avatar of ndcollins
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_GivingBeta">
        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?confirmadd=#confirmadd#">
ASKER CERTIFIED SOLUTION
Avatar of wytcom
wytcom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ndcollins
ndcollins

ASKER

This is MySQL, not MS SQL. In any case, I did try that and still no joy.
Your comment did make me think of a couple other things to try through, and I've now got it working. Thanks!