How do you pass variables in ColdFusion to MySQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Hackenbur
    New Member
    • Feb 2011
    • 1

    How do you pass variables in ColdFusion to MySQL?

    Hi All,
    I am trying to figure out coldfusion. I previously used php mysql website development, but my friend decided to use the coldfusion setup and now is needing help. Now I keep getting the error "Error: Element Undefined in Form".

    Code:
    <cfquery name="auto" datasource="mysqlcf_auto" dbname="auto" username="auto" password="pswd1">
    
      INSERT INTO Customer
      (FName,MName,LName,Phone,Cell,Email,Location) 
      VALUES
      ('#form.PURFirstName#', '#PURMiddleName#', '#PURLastName#', '#PURPhoneNumber#', '#PURCellNumber#', '#PUREmail#', '#PURContactLocation#')
    </cfquery>
    Any help is appreciated!
  • cfEngineers
    New Member
    • Feb 2011
    • 2

    #2
    Put a
    Code:
    <cfdump vars="#form#"></cfabort>
    at the top of your page

    This will dump out any variable that are in available in the form scope.

    You have the right idea in your query using the variables.

    I would also strongly suggest you use cfqueryparam tag to protect from SQL injection attacks
    Here is the link to the online docs


    Hope that helps

    Comment

    • Ajo Koshy Josep
      New Member
      • Mar 2011
      • 5

      #3
      Check the elements PURFirstName,PU RMiddleName,PUR LastName,PURPho neNumber,PURCel lNumber,PUREmai l and PURContactLocat ion whether they exist in form or has a different spelling. The query is not getting the written element from the form.

      Comment

      Working...