Skip to main content
June 20, 2009
Question

cfqueryparam

  • June 20, 2009
  • 1 reply
  • 1240 views

I am trying to process a form with multiple words entered with a single <cfinput type="text"...> tag. When I try and process the form, I get this error:

"Parameter 1 of function SetVariable, which is now text, must be a syntactically valid variable name"

on the line of the <cfqueryparam> tag in the update query. If I enter a sinlge word into the form element, I don't get an error. any recomendations.

    This topic has been closed for replies.

    1 reply

    BreakawayPaul
    Inspiring
    June 20, 2009

    Can you post your actual code?

    June 20, 2009

    Sure!

    Form field:


    <CFFORM ACTION="processpage.cfm">

    <cfinput type="text" 
                  name="textentry"
                  value="#Trim(GetContact.textentry)#">

    </CFFORM>

    process page:

    <CFQUERY DATASOURCE="db">
                            UPDATE exampletable
                            SET Interest = <cfqueryparam value="#FORM.texentry#" cfsqltype="cf_sql_varchar">

    </CFQUERY>

    BreakawayPaul
    Inspiring
    June 21, 2009

    Just talking a peek before bed, but I'll note that the name attribute is required for cfquery.

    <cfquery name="myquery" datasource="db">

    I don't know your db structure, but I'm used to seeing a WHERE clause with an update, otherwise you'll set every row in the table so that the "Interest" column equals your value.  If you only have one row, that's fine, or if you intend to update all the rows, that's fine.

    If adding a name= to the query doesn't fix it, we'll look at things more closely.