Ask a Question related to Coldfusion Database Access, Design and Development.
-
caledoniaman #1
Escape character in SQL - how do I ignore ?
I have laboured through the joys of importing a CSV file and sticking the
values in a MySQL database. So far so good.
However the CSV file contains a value as follows :-
"W\'hampton/Birmingham"
As a result of this my SQL falls over. I'm presuming it's because of the \
Can anyone shed any light on whether this is :-
a) indeed the case and
b) how to rectify this, bearing in mind that the query is generated on the fly
for each line in the CSV file. I also have no control over the content of said
file.
Many thanks in advance.
Mark.
caledoniaman Guest
-
#37262 [Asn->Csd]: var_export() does not escape \0 character
ID: 37262 Updated by: iliaa@php.net Reported By: idiom at mail dot ru -Status: Assigned +Status: ... -
No escape character with dircect method call in cfquery
Hello, I found the follwing behavior when I tried to use a method call directly in a <cfquery>. In this case single quote characers will not be... -
Escape character when setting variable
I'm unsure on how to escape a character when setting a session variable. Here's my problem, I'm getting an outside variable that contains a dash in... -
[PHP] explode and escape character for string separator
One set of delimiters I often use for text files is ~~ or ^^. They are fairly unique. If they do appear in a file then there is probably garbage in... -
explode and escape character for string separator
--- "Reuben D. Budiardja" <reubendb@innovativethought.com> wrote: You should strive to make your delimiter unique. A delimiter that might... -
caledoniaman #2
Re: Escape character in SQL - how do I ignore ?
OK, this is obviously not one which many people have encountered before. Maybe
I could approach it from a different angle and see if you can help me.
In between the <cfquery> tags I am declaring my SQL in a string variable. How
can I take this string and remove any '\' characters (which will eliminate this
problem) ?
Thanks again in advance.
caledoniaman Guest
-
mxstu #3
Re: Escape character in SQL - how do I ignore ?
If you're going to be doing this on a regular basis, you'll probably end up
creating a udf that scrubs the text values, but for now, you could use a simple
replace() to escape the "\":
<cfset yourValue = "W\'hampton/Birmingham">
<cfset newValue = Replace(yourValue, "\", "\\")>
<cfquery name="test" datasource="#yourDSN#">
INSERT INTO test (yourColumn)
VALUES ( '#newValue#' );
</cfquery>
mxstu Guest



Reply With Quote

