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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to