Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

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#">
0
ndcollins
Asked:
ndcollins
  • 2
1 Solution
 
wytcomCommented:
With MS SQL, I would omit the autoincrement fields from the query.  You could try removing both the field name and the associated blank value.
0
 
ndcollinsAuthor Commented:
This is MySQL, not MS SQL. In any case, I did try that and still no joy.
0
 
ndcollinsAuthor Commented:
Your comment did make me think of a couple other things to try through, and I've now got it working. Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now