Skip to main content
Inspiring
August 9, 2010
Question

cannot insert form data

  • August 9, 2010
  • 2 replies
  • 972 views

Hi again, ok i changed approaches form cfinsert to  using a query. Since then I have not go the form to submit. OS Windows 7,  CF8 and Access 2010 db

please see code:

action page::

<cfif not IsDefined("form.vendorTraining")>
<cfset form.vendorTraining ="NO">
</cfif>

<cfif not IsDefined("form.noAssist")>
<cfset form.noAssist ="NO">
</cfif>

<cfif not IsDefined("form.crabTraining")>
<cfset form.crabTraining ="NO">
</cfif>

<cfif not IsDefined("form.callMail")>
<cfset form.callMail ="NO">
</cfif>

<cfquery name="survey1" datasource="dsSurvey">
       
       
        INSERT INTO designSoftwareSurvey
        
       
       
      
       
       
        VALUES  ('#form.contactPerson#',
          '#form.jobPosition#',
                '#form.contactEmail#',
                '#form.county#',
                '#form.civilUsed#',
                #form.civilLicenses#,
                '#form.civilSat#',
                '#form.civilInterests#',
                '#form.surveyUsed#',
                #form.surveyLicenses#,
                '#form.surveyDownload#',
                '#form.surveyUpload#',
                 '#form.surveySat#',
                '#form.surveyInterests#',
                '#form.surveyProcess#',
                '#form.cadUsed#',
                #form.cadLicenses#,
                 '#form.cadSat#',              
                '#form.cadInterests#',
                '#form.hydroUsed#',
                #form.hydroLicenses#,
                '#form.otherIssue#',
                '#form.cost#',
                '#form.training#',
                '#form.hardware#',
                '#form.agree#',
                '#form.management#',
                '#form.noAssist#'
                '#form.callmail#',
                '#form.crabTraining#',
                '#form.vendorTraining#',
                '#form.praise#',
                '#form.cons#',
                '#form.addComments#',
                '#form.hydroInterests#' )
               
        </cfquery>

<cfoutput>Thank you #form.contactName# for completing the Software survey.</cfoutput>

Error Executing Database Query.

Syntax error (missing operator) in query expression ''yes' 'yes''.
The error occurred in C:\Webroot\Crabweb1a\Technology\DesignSystems\softwareSurvey\confirmSurvey2.cfm: line 508
506 :                 '#form.cons#',
507 :                 '#form.addComments#',
508 :                 '#form.hydroInterests#' )
509 :                 
510 :         </cfquery>

SQLSTATE
SQL   INSERT INTO designSoftwareSurvey (contactPerson, jobPosition, contactEmail, county, civilUsed, civilLicenses, civilSat, civilInterests, surveyUsed, surveyLicenses, surveyDownload, surveyUpload, surveySat, surveyInterests, surveyProcess, cadUsed, cadLicenses, cadSat, cadInterests, hydroUsed, hydroLicenses, otherissue, cost, training, hardware, agree, management, noAssist, callmail, crabTraining, vendorTraining, praises, cons, addComments, hydroInterests) VALUES ('fasdf', 'fdsaf', 'fasdf@c.com', 'Yakima', 'asa', 1, '6', 'fddf', 'sd', 1, 'YES', 'YES', '2', 'dsd', 'dsd', 'dsd', 2, '3', 'dsds', 'dsds', 1, 'cxcx', '3', '3', '3', '3', '3', 'yes' 'yes', 'yes', 'NO', 'cxc', 'cz', 'czxc', 'cxxcxc' )
VENDORERRORCODE  3092

    This topic has been closed for replies.

    2 replies

    Inspiring
    August 9, 2010

    You might also use CFPARAM to provide default values.

    Instead of:

    <cfif not IsDefined("form.vendorTraining")>
    <cfset form.vendorTraining ="NO">
    </cfif>

    You can use:

    <cfparam name="form.vendorTraining" default="NO">

    Inspiring
    August 9, 2010

    'yes' 'yes'

    You are missing a comma in between two of the inserted values.

    A good tip I have seen in these forums is to always place commas before the values. The formatting obviously has little impact on the sql. But personally I find it helps reduce "missing comma" errors and makes them easier to spot.

    VALUES

    (

    '#firstValue#'

    , '#secondValue#'

    , '#thirdValue#'

    , '#fourthValue#'

    )

    You might also take a look at using cfqueryparam.

    rockhikerAuthor
    Inspiring
    August 9, 2010

    Yes I was missing a comma, nice catch, I did not see it afer several checks. I am new to cfparam and I have not found a clear example when submitting forms on how to use.

    How do I use it?  Do I list cfparams for all of my fields at the top of the action page? OR just certain ones. for example how would you do a cfparam for a memo field.?