> This must be a basic question, but I found no real answer on the allaire
> forums.
>
> I want to allow users to enter apostrophes in text, which I then
> save to the database.  However, the sql insert will fail as it interprets
> this apostrophe within the text as one of the apostrophes surrounding the
> text.
>
> Example:
>
> INSERT INTO tblUserComments (userid, usercomment)
> VALUES (12345, 'I don't know what to think')
>
> This fails on the ' in don't
>
> There must be a better solution than HTMLEditFormat.

OK, here's how it works - you use PreserveSingleQuotes() to keep
apostrophies if you're building the SQL in a string before you pass it to
CFQuery

If you want to put an apostrophie into a field, then you must double it;
Replace(myField,"'","''","all")

As SQL uses the apostrophies to begin and end a field, you have to tell SQL
that it's not the end of the field

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to