Professional Web Applications Themes

removing quotes in form field - Coldfusion - Advanced Techniques

I'm running CFMX 6.1 on our server. I have two form fields (type=text on one of them and the other is type=textarea) which post to a results page. I use these two fields in my MySQL insert statement to populate a database table. ISSUE: The script works fine for populating whatever the user types in the two form fields as long as they don't start and end the text typing with quotations. ie: "The data entry in this form field." I've tried REReplace, Replace, HTMLeditformat() in about as many variations as I've found on this forum. The simplest thought was ...

  1. #1

    Default removing quotes in form field

    I'm running CFMX 6.1 on our server.

    I have two form fields (type=text on one of them and the other is
    type=textarea) which post to a results page. I use these two fields in my
    MySQL insert statement to populate a database table.

    ISSUE: The script works fine for populating whatever the user types in the two
    form fields as long as they don't start and end the text typing with
    quotations. ie: "The data entry in this form field."

    I've tried REReplace, Replace, HTMLeditformat() in about as many variations as
    I've found on this forum.

    The simplest thought was either to use

    Replace(form.field1,'"','','all')
    Then I tried
    Replace(form.field1,chr(34),"","all")

    I've tried <cfqueryparam value="#form.field1#" cfsqltype="cf_sql_varchar">
    since my fields are varchar in MySQL and it still won't populate any data in
    the field in my insert statement.

    I'm at a loss after combing these forum posts as far back 2000.

    HELP!

    Phox68 Guest

  2. #2

    Default Re: removing quotes in form field

    Try using double quotes instead of single quotes here
    Replace(form.field1,'"','','all')

    It's worth a shot.
    Dan Guest

  3. #3

    Default Re: removing quotes in form field

    I've already tried a multitude of variations on the "" and ' ' . I still don't know how to accomplish this goal as it seems so silly. HELP!
    Phox68 Guest

  4. #4

    Default Re: removing quotes in form field

    Would replacing the quotes with "'" work in your situation?
    SteveBryant Guest

  5. #5

    Default Re: removing quotes in form field

    1) I don't think there is any need for cfqueryparam.
    2) I would suggest that, rather than remove quotes, you actually add more
    quotes as an "escape" mechanism. For data integrity you should store what the
    client sends you. He may be telling a story that begins with a quotation mark
    and
    ends with a quotation mark, requring you to store the information as-is.

    One of course escapes quotes with quotes in Coldfusion. So, something like
    this
    should do it.
    <cfset testVar=Replace(form.myField,chr(34),"""""","all") >
    <cfquery name="q" datasource="My_DSN">
    insert into testtable values('#testVar#', 'aaaa','bbbb','cccc','on',3,'ffff');
    </cfquery>

    Still, I'm puzzled why you can't directly do
    <cfquery name="q" datasource="My_DSN">
    insert into testtable values('#form.myField#',
    'aaaa','bbbb','cccc','on',3,'ffff');
    </cfquery>

    BKBK Guest

  6. #6

    Default Re: removing quotes in form field

    Well, I've tried the "escape" route and the result is that the first instance
    of the form field phrase is replaced with the word

    all

    So the data form field I'm trying to submit is

    "What's next?"

    And what is happening is

    allWhat's next?"

    This didn't solve anything either.

    I'm just as puzzled as ever. Still no solution.

    Phox68 Guest

  7. #7

    Default Re: removing quotes in form field

    I've managed to get it to work doing the following

    Replace("form.myfield","""","'","all")

    This puts the HTML in the database, which makes it work fine.
    Phox68 Guest

Similar Threads

  1. Removing Quotes
    By CherylHCG in forum Macromedia ColdFusion
    Replies: 4
    Last Post: March 25th, 02:22 PM
  2. Replies: 3
    Last Post: May 13th, 12:15 AM
  3. Smart Quotes in Dynamic text field
    By bwillidesign webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 30th, 12:55 AM
  4. single quotes in database field breaks form?
    By Greg in forum PHP Development
    Replies: 6
    Last Post: December 14th, 12:38 AM
  5. Creating a calculated field with quotes
    By Rich Sagall in forum FileMaker
    Replies: 8
    Last Post: September 28th, 02:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139