Need help with preserving double quotes in text fields
Hi all,
I've built a form that allows a user to type in whatever they want into a textarea field.
That field is then inserted into a database table with a field named 'page_text' and that specific field is varchar(6000).
The problem I'm having isn't making any sense to me.
For instance, if someone were to type:
Former President Reagan once said, "We can not have an economy based on delivering pizza to one another", which is often misquoted
..when the insert statement runs, what ends up in the page_text field is the following:
Former President Reagon once said,
..and it stops right where the first double-quote shows up in the textarea input of the user.
I understand the need to escape double quotes in instances where double quotes are used in query syntax, but in the case of an insert statement
the code does not use double quotes, it uses single quotes around the value.
But, for whatever reason, which I am resigned to accepting, the double quotes seem to cause issues. Thus, I assume I need to find a way to escape the double quotes contained within the submitted textarea field.
I have tried different things. I tried using ReReplace on the value to exchange the double quotes for ascii charactors. I have tried to use ReReplace to exchange a single double quote for a set of two double quotes (side by side). I have tried using cfqueryparam value="#text#" cfsqltype="CF_SQL_VARCHAR", as well as cfqueryparam value="#form.text#" cfsqltype="CF_SQL_VARCHAR" directly in the input query, and all have failed to get past this issue.
Using the cfsqltype code actually throws an error about something being a '1', when no '1' exists in the text being processed.
Using the various ReReplace methods does not throw an error, but the resulting contents of the page_text field are cut off at the first double quote found in the passed textarea content.
I'm not sure whether I am supposed to parse out the double quotes completely, try a ReReplace of some kind, use some type of code 'before' the data even reaches the insert query, or do something to manipulate it directly in the insert query itself.
I've run out of ideas, and while searching both the general internet and these forums, I am only finding references to single quote problems (preserveSingleQuotes) and not double quote issues.
If anyone has any idea on how to get past this problem, I'd be greatly appreciative. The amount of yelling and cussing that has enveloped my office over this problem is getting a bit extreme ![]()
Thank you,
WHeis
PS.
Here are some things I've tried:
reReplace(blogtextpost, "(#Chr(34)#)","""","ALL")
reReplace(blogtextpost, ""","""","ALL")
reReplace(blogtextpost, """","""""","ALL")
reReplace(blogtextpost, ' " ',' "" ',"ALL")
as well as the previously mentioned cfsqltype lines
