actually the single quotes for the SQL are not in my variable..
lets say my variable is..

<cfset foo = " this is a test '\' text " >
<cfset foo = replacenocase(foo, "\", "\\" , "ALL")> // escape the ( \ )

when i do

INSERT INTO foo (field) values('#foo#' <---- it will look like ( 'this is a
test ''\\'' text' )

and that is when i get the error message...

now if my text has just a single \ it wont say anything but its the
combination of '\' that screws it up..
ill try that #preserveSingleQuotes(foo)# to see if it does something :)


----- Original Message -----
From: "Bryan Love" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, December 03, 2001 11:59 AM
Subject: RE: problems with backslash and quotes..


> It looks like the single quotes are in your variable.  In that case CF
will
> automatically escape them when you reference the variable in a CFQUERY:
>
> <cfset foo = "'\'">
> <cfquery.....>
> INSERT INTO...
> VALUES( '#foo#' <- this will be '''\'''
> </cfquery>
>
> you can prevent this by using the preserveSingleQuotes() function.  If you
> do that you wouldn't need to put single quotes in the VALUES() clause
either
> since the variable already has them:
>
> <cfset foo = "'\'">
> <cfquery.....>
> INSERT INTO...
> VALUES( #preserveSingleQuotes(foo)# <- this will be '\'
> </cfquery>
>
> +-----------------------------------------------+
> Bryan Love
>   Macromedia Certified Professional
>   Internet Application Developer
>   Database Analyst
> Telecomunication Systems
> [EMAIL PROTECTED]
> +-----------------------------------------------+
>
> "...'If there must be trouble, let it be in my day, that my child may have
> peace'..."
> - Thomas Paine, The American Crisis
>
>
>
> -----Original Message-----
> From: Alexis Maldonado [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 03, 2001 9:13 AM
> To: CF-Talk
> Subject: problems with backslash and quotes..
>
>
> I created an app using Access and Mssql7.
>
> it works perfect on it but i need to get it to run on Postgresql and
Mysql.
>
> The problem im having is that everytime i try to run an insert from a text
> field or file into the database
> and the text field contains a backslash it fails..
> i have tried doing:
> replacenocase(string,"\","\\","ALL");
> and it seems to work fine until i run into a text that has '\'
> (quote-backslash-quote)
> then my query fails.. it looks something like this..
>
> Inser into table (column) values('''\''')
>
> it gives me a parse error..
>
> is there a simple way of fixing this? a tag maybe?
>
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to