|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Loosing Characters during cfdirectory and cfquery
Im using cfdirectory to read a directory, and then adding the filename, size, directory into mysql 5 database.
Code:
<cfdirectory action="list" directory="D:\Backup\Cv'z" name="files" sort="Name desc" recurse='true' >
<cfset a = 1>
<cftable query="files" colheaders="yes" htmltable="no" border="yes" maxrows="10">
<cfcol text="#a#" >
<cfcol text="#type#">
<cfcol text="#size#">
<cfquery datasource="Intranet" name="addcv">
Select * from files
where File_Name = '#name#'
and File_Folder = '#directory#'
</cfquery>
<!--- Inserts file into DB ---->
<cfquery datasource="Intranet" name="insertCV">
Insert into files
(File_Name, File_Folder, File_Size)
values
('#name#', '#directory#', '#size#')
</cfquery>
<cfif addcv.recordcount gt 0>
<cfcol text="<font color=red>#name#</font>">
<cfelse>
<cfcol text="#name#">
</cfif>
<cfcol text="#directory#\#name#">
<cfset a = a + 1>
</cftable>
It inserts D:BackupCv'zSalesTyped Cvs instead of d:\BackupCv's\Sales\Typed CVs Why is it removing the \'s ? |
|
#2
|
|||
|
|||
|
Try using cfqueryparam in the insert. I speculate that the single quote in the directory name is screwing something up. cfqueryparam is best practice anyway, and should be used with ALL queries for many reasons, including better performance and avoiding SQL injection attacks.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
MySQL removes the backslashes for some reason, so you'll have to double them up:
<CFSET directory=Replace(directory,"\","\\","ALL")> Peter |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Loosing Characters during cfdirectory and cfquery |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|