If you're using CF variables in your SQL you may* need to escape any
single quotes when you're creating your SQL statement in the first
place:

<cfset user = "Barney O'Boivert">
<cfset sql = "select * from mytable where name = '#Replace(user, "'",
"''", "all"))#'" />
<cfquery ... >
   #preserveSingleQuotes(sql)#
</cfquery>

Bert

* if there's any chance they will contain single quotes then you'll
need to escape them

On Thu, 9 Dec 2004 08:23:07 -0800, Barney Boisvert <[EMAIL PROTECTED]> wrote:
> I use preserveSingleQuotes with MySQL without any issue.  You
> shouldn't need to do anything special:
> 
> <cfset sql = "select * from mytable where name = 'barneyb'" />
> <cfquery ... >
>   #preserveSingleQuotes(sql)#
> </cfquery>
> 
> 
> 
> 
> On Wed, 8 Dec 2004 18:08:02 -0500, C. Hatton Humphrey
> <[EMAIL PROTECTED]> wrote:
> > > Why not just double up the single quotes?
> >
> > Tried that - may be a NDA thing or just a MySQL thing - I got the same
> > error when sending the query.
> >
> > To answer Barney's question - I'm using a MySQL database.  That's what
> > the clent has and I haven't been able to dissuade him from using it.
> >
> > When I sent the query "select orders_id from orders where label =
> > '#This_Label#' ..." I get a SQL error showing the doubled-up quotes.
> >
> > Hatton
> 
> --
> Barney Boisvert
> [EMAIL PROTECTED]
> 360.319.6145
> http://www.barneyb.com/blog/
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186926
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to