473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem with a db with filenames

HI all

I have a database where one field contains paths to files
ex (images\here_1todo.jpg)

no i'm writing in php a query to select some filenames but i cant work out
al the escapes...

for example
SELECT * FROM Matador_base WHERE Archivo LIKE
'%".AddSlashes(str_replace('_','\_',$arch))."%'",$ db);
does work with $arch = images\here_1
but not with $arch = images\here_1tod

why, what am i missing, how to resolve

thnx
Gerrit
Jul 19 '05 #1
2 1684

"Gerrit" <ge****@NOSPAMportaltaurino.com> wrote in message
news:3f***********************@news.xs4all.nl...
HI all

I have a database where one field contains paths to files
ex (images\here_1todo.jpg)

no i'm writing in php a query to select some filenames but i cant work out
al the escapes...

for example
SELECT * FROM Matador_base WHERE Archivo LIKE
'%".AddSlashes(str_replace('_','\_',$arch))."%'",$ db);
does work with $arch = images\here_1
but not with $arch = images\here_1tod

why, what am i missing, how to resolve

thnx
Gerrit


Have you tried htmlentities() before writing your data to the db or
urlencode() or something?

If magic quotes is turned on (it is I believe by default in your php
installation) then you shouldn't have to do much else (perhaps someone else
will correct me here). If you do want to mangle the file name, try using
htmlentities() or urlencode() as opposed to addslashes - Otherwise if you're
not careful you'll end up with PHP (with magic quotes on) adding a slash,
then your addslashes() function adding another slash and just confuse the
hell out of you... You can find out if magic quotes is on by viewing the
output of phpinfo and search for the word magic.

When you say $arch=images\here_1 works, and $arch=images\here_1tod fails, do
you get an error (do you have error reporting on)? Is your column wide
enough in the table? It will chop it if you try to give it too much.

Also, have you tried your query from a mysql client command line before
going to the browser as some characters might get converted in to illegal
html format meaning unless you do a View Source to your web page, you won't
see the results.

Hope that gives you somethin' to work on... and I hope (as a reasonable
newbie to MySQL that I've not steered you up the wrong path).

randell d.
Jul 19 '05 #2

"Gerrit" <ge****@NOSPAMportaltaurino.com> wrote in message
news:3f***********************@news.xs4all.nl...
HI all

I have a database where one field contains paths to files
ex (images\here_1todo.jpg)

no i'm writing in php a query to select some filenames but i cant work out
al the escapes...

for example
SELECT * FROM Matador_base WHERE Archivo LIKE
'%".AddSlashes(str_replace('_','\_',$arch))."%'",$ db);
does work with $arch = images\here_1
but not with $arch = images\here_1tod

why, what am i missing, how to resolve

thnx
Gerrit


Have you tried htmlentities() before writing your data to the db or
urlencode() or something?

If magic quotes is turned on (it is I believe by default in your php
installation) then you shouldn't have to do much else (perhaps someone else
will correct me here). If you do want to mangle the file name, try using
htmlentities() or urlencode() as opposed to addslashes - Otherwise if you're
not careful you'll end up with PHP (with magic quotes on) adding a slash,
then your addslashes() function adding another slash and just confuse the
hell out of you... You can find out if magic quotes is on by viewing the
output of phpinfo and search for the word magic.

When you say $arch=images\here_1 works, and $arch=images\here_1tod fails, do
you get an error (do you have error reporting on)? Is your column wide
enough in the table? It will chop it if you try to give it too much.

Also, have you tried your query from a mysql client command line before
going to the browser as some characters might get converted in to illegal
html format meaning unless you do a View Source to your web page, you won't
see the results.

Hope that gives you somethin' to work on... and I hope (as a reasonable
newbie to MySQL that I've not steered you up the wrong path).

randell d.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lentdave67t | last post by:
Thank you in advance for any help you can provide. I am writing a C# program that checks to see if the URLs of favorites/bookmarks are still good. The problem I am having is that while the...
2
by: Lentdave67t | last post by:
Thank you in advance for any help you can provide. I am writing a C# program that checks to see if the URLs of favorites/bookmarks are still good. The problem I am having is that while the...
1
by: Tanuki | last post by:
Hi: I have a problem regarding filenames in Visual C++. I would like to read from files using relative filenames instead of absolute filenames. I have tried using the following fname =...
4
by: Anthony Lansbergen | last post by:
Hi, My (pre)compiler(s) (borland C++ builder 5 and g++) both seems to have a problem with the new include format. In stead of #include <iostream.h> I want to say #include <iostream>. This...
2
by: DaveF | last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2 minutes and then download the files. Then repeat every 2 minutes. The files just seem to stop downloading. Does that timer...
1
by: Fatemeh | last post by:
Hi I want to write a program (FileCopier) that it allow the user to check files (or entire directories) in the left tree view (source). If the user presses the Copy button, the files checked on...
4
by: skavan | last post by:
Use Case: We have music files that describe, in their filename, attributes of the music. We do not know a general pattern that applies to all filenames -- but we do know that filenames that are...
1
by: Jarry | last post by:
I just play around mainly in javascript, and I was making a web page (http://www.freewebs.com/prugle/games.htm). I have asked a few people to look at it, and so I have. Some people can see the...
5
by: kimiraikkonen | last post by:
Hello, I have openfiledialog control named "openfileplaylist" and multi- selectpropert is TRUE. But although i select more than one files using "shift+arrows", i only get one file listed in my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.