You need to escape the quotes that you're using to delimit text fields in your
SQL. This is done by doubling the embedded quotes. For example:
If you use single quotes to delimit text in your SQL:
INSERT
INTO tblMyStuff ( Comment )
VALUES ( 'Here's my comment' )
will explode, whereas
INSERT
INTO tblMyStuff ( Comment )
VALUES ( 'Here''s my comment' )
will work OK. So a
Replace(txtComment,"'","''","ALL")
should do the trick for the field where you're expecting quotes to be entered
(txtComment). If you're using double quotes, the function would be
Replace(txtComment,"""","""""","ALL")
Count those quotes carefully--there are four in the first argument (two outer
ones to delimit the string, and two inner ones representing one double-quote
character [escaped]), and six in the second (same logic, but with two escaped
double-quote characters in the middle).
- Jeff
On 16 May 2001, at 9:04, Nichols, Robert H. wrote:
> More of a CF question than a fusebox question, though it is taking place in
> a fusebox enabled application.... :)
>
> I have a form with a text area for the client to enter comments. the trick
> though is that I have to allow the user to type single quotes (') and double
> quotes (") along with whatever other strange variables they want. However,
> I am choking when I try to insert their queries into the database. has
> anyone ever done this? if so, how did you do it?
>
> The only thing I have come up with so far is URLEncoding it before placing
> it in the database and the URLDecoding it when it comes out. However, that
> seems overtly complicated. Can anyone suggest a better way?
>
> Robert H. Nichols
> Web Developer
> Center for Engineering & Environmental Technologies
> Information Delivery Systems <http://ids.rti.org>
> Research Triangle Institute
> Voice: 919-541-8009 Fax: 919-541-6936
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists