• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error in inserting data into tables... '/'

LEGEND ,
Sep 09, 2007 Sep 09, 2007

Copy link to clipboard

Copied

I am trying to use cfhttp to create a query out of a text file and then loop
and insert it into a database. Easy enough and works fine. However, I am
getting a forward slash in some of the fields which is causing an error.
'SOUTH OF SOUTH BLVD AND EAST OF BEACH RD\'

It is being entered into a LONGTEXT field in MySQL 5. Any way to get the '\'
to be ignored and just be entered?

Here is my script block:

<cfhttp timeout="3600" url=" http://www.bpoprosonline.com/property/#ResFile#"
method="GET" name="Property" delimiter="|" textqualifier=""
firstrowasheaders="yes" />
<cfloop query="Property">
<cfquery name="loopProperty" datasource="bpopros">
Insert Into Property
(MLSNumber, ListOfficeCompany, ListOfficeId, Basement, Baths, BFK_Dimen,
BR2_Dimen, BR3_Dimen, BR4_Dimen, BR5_Dimen, City, County, Din_Dimen,
Directions, Directions_E_W, Directions_N_S, East_West, Fam_Dimen, Fireplace,
Garage, Grt_Dimen, Kit_Dimen, Lib_Dimen, ListPrice, Liv_Dimen, Lot_Dimen,
MBR_Dimen, No_Bedrooms, North_South, Remarks1, Remarks2, Remarks3, Remarks4,
Remarks5, Remarks6, School_District, State, Street_Dir, StreetName,
StreetNumber, SummerTax, Tot_Baths, Tot_Lavs, Tot_Square_Feet, Winter_Tax,
Year_Built, Zip5, Appliances, Basement_Type, Bath_Desc, Cooling, Exterior,
Foundation, Garage_Type, Heating, Other_Rooms, Site_Desc, Style, PhotoURL,
DisplayAddress, Agent, weight)
VALUES
(
<cfif #MLSNumber# EQ "">0<cfelse>#MLSNumber#</cfif>,
'#ListOfficeCompany#',
<cfif #ListOfficeId# EQ "">0<cfelse>#ListOfficeId#</cfif>,
'#Basement#',
<cfif #Baths# EQ "">0<cfelse>#Baths#</cfif>,
'#BFK_Dimen#',
'#BR2_Dimen#',
'#BR3_Dimen#',
'#BR4_Dimen#',
'#BR5_Dimen#',
'#City#',
'#County#',
'#Din_Dimen#',
'#Directions#',
'#Directions_E_W#',
'#Directions_N_S#',
'#East_West#',
'#Fam_Dimen#',
'#Fireplace#',
'#Garage#',
'#Grt_Dimen#',
'#Kit_Dimen#',
'#Lib_Dimen#',
<cfif #ListPrice# EQ "">0<cfelse>#ListPrice#</cfif>,
'#Liv_Dimen#',
'#Lot_Dimen#',
'#MBR_Dimen#',
<cfif #No_Bedrooms# EQ "">0<cfelse>#No_Bedrooms#</cfif>,
'#North_South#',
'#Remarks1#',
'#Remarks2#',
'#Remarks3#',
'#Remarks4#',
'#Remarks5#',
'#Remarks6#',
'#School_District#',
'#State#',
'#Street_Dir#',
'#StreetName#',
'#StreetNumber#',
'#SummerTax#',
<cfif #Tot_Baths# EQ "">0<cfelse>#Tot_Baths#</cfif>,
<cfif #Tot_Lavs# EQ "">0<cfelse>#Tot_Lavs#</cfif>,
<cfif #Tot_Square_Feet# EQ "">0<cfelse>#Tot_Square_Feet#</cfif>,
'#Winter_Tax#',
<cfif #Year_Built# EQ "">0<cfelse>#Year_Built#</cfif>,
<cfif #Zip5# EQ "">0<cfelse>#Zip5#</cfif>,
'#Appliances#',
'#Basement_Type#',
'#Bath_Desc#',
'#Cooling#',
'#Exterior#',
'#Foundation#',
'#Garage_Type#',
'#Heating#',
'#Other_Rooms#',
'#Site_Desc#',
'#Style#',
'#PhotoURL#',
'#DisplayAddress#',
0,
<cfif #ListOfficeId# EQ 340169>1<cfelse>0</cfif>)
</cfquery>
</cfloop>


Thanks

--
Wally Kolcz
MyNextPet.org
Founder / Developer
586.871.4126


TOPICS
Advanced techniques

Views

245

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2007 Sep 09, 2007

Copy link to clipboard

Copied

In short, I need to search for and escape the \ character in a field prior
to insert.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2007 Sep 09, 2007

Copy link to clipboard

Copied

Ok, first I am looking for the character using <cfif #field# CONTAINS
"\">'Error'<cfelse>'#field#'</cfif> and that is working so far. Now I just
need to escape the \.

I am going to try replace(#field#, "\", "\\", "ALL").

Will that work or any better ideas?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2007 Sep 09, 2007

Copy link to clipboard

Copied

What happened when you tried it? Did you have a similar problem with apostrophes?

cfqueryparam will probably escape all the weird characters you are likely to encounter.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2007 Sep 09, 2007

Copy link to clipboard

Copied

LATEST
It seemed to have worked. I managed to loop and insert 55,345 records
without a hitch. I may move it to a cfqueryparam and see if that works too.

"Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
news:fc1r5n$dal$1@forums.macromedia.com...
> What happened when you tried it? Did you have a similar problem with
> apostrophes?
>
> cfqueryparam will probably escape all the weird characters you are likely
> to encounter.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation