473,372 Members | 1,048 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,372 software developers and data experts.

opendir and current path problem ?

Greetings,

I hope my problem is easy to fix, I'm pretty new with php - but I am
getting weird results with the opendir() function. It may just be a
path problem, but I don't see which variable to change.

here are some tests I did to see what was wrong:

$blah = opendir("blocks");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}

$blah = opendir("modules");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}

$blah = opendir("images");
while ($file = readdir($blah)) {
writelog("$file", DEBUG);
}
In the 1st and 3rd while()'s, it correctly picks the "blocks" and
"images" directories of my doc_root path (which is the path I get when
I try a getcwd()). However, the second while() lists me the files
contained in the "modules" directory of my server root (apache's
modules directory) instead of picking the "modules" directory in the
current dir. (both apache and the doc_root contain a 'modules'
directory). I know I could probably get around the problem using full
paths, but this is from phpnuke, so I'd like to keep the original code
intact and would prefer changing a config somewhere if possible.

Note that the very same server configuration on a win2k or on a winxp
do not give this problem, so I'm guessing it's a NT-related problem.
It's as if it's checking a list of directories in a path instead of
the current directory and the server_root happens to come before
doc_root.

Bug or feature ? Configuration problem ?
Thanks

FP
Aug 23 '05 #1
4 3307
Just a thought, try renameing that directory to something more random
and see if you still get the same result... it may be the choice of
"modules" as a directory name that is confusing it.

Aug 23 '05 #2
I already tried creating a "images" directory in apache's root
directory (same place where the 'modules' directory is) and put some
random files in it - I reloaded the page and this time it listed the
newly created "images" directory instead of phpnuke's. So it's a
question of identical directory names and paths, not just for the name
"modules".

Thanks anyway ;)
On 23 Aug 2005 08:10:09 -0700, r.*********@gmail.com wrote:
Just a thought, try renameing that directory to something more random
and see if you still get the same result... it may be the choice of
"modules" as a directory name that is confusing it.


Aug 23 '05 #3
Take a look at your include path in php.ini. It may be looking in ./,
then ../, then elsewhere. What happens when you specify the complete
path to the directory in your call to opendir() ?

Aug 23 '05 #4
Hi, sorry for the delay...

Putting the full paths work, as I expected.
My php.ini include path is:
include_path = ".;C:\apachefriends\xampp\php\pear\"

The . is the current directory I think, though logically that would be
apache\bin rather than apache\. However, as I said, this very same
configuration does not give me the problem on a Win2k/XP machine. So
I figure it's WinNT that's being weird here.

For now I think I will simply move the site on a different server
rather than waste time modifiying code - it's just a few lines to fix,
but who knows what other surprises this kind of problem might give me
later...

Anyway, if anyone sees where the bug is, feel free to join in..

later,

Fp
On 23 Aug 2005 10:11:05 -0700, "ZeldorBlat" <ze********@gmail.com>
wrote:
Take a look at your include path in php.ini. It may be looking in ./,
then ../, then elsewhere. What happens when you specify the complete
path to the directory in your call to opendir() ?


Aug 29 '05 #5

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

Similar topics

9
by: Andrew DeFaria | last post by:
I'm attempting to put my music collection on the web using PHP and I hit a problem. When I attempt an opendir of a directory that contains a "'" character the opendir fails. Here's the code...
1
by: Bob Gervais | last post by:
Hi, I am writing a very simple script that should return all subdirectories on a given path (non recursively, so just first level). This is the sub that I have for doing this but it gives very...
2
by: Alex | last post by:
Greetings all, I'm trying to use the "opendir" command on Win32 in a CGI script. I'm using Apache 2.0.48 for Win32. The "openDir" command works from the CGI script when I try to open a...
5
by: Markus Pitha | last post by:
Hello, i'm using Gentoo Linux and like to open directories which i got from a text file i read of. I tried to open a directory as i wrote the directory name directly into "opendir()" and it...
6
by: dmcglynn | last post by:
Hello all.. I have a strange issue. I am trying to do an opendir via a UNC path, from my windows server to another windows machine. As long as my remote machine is on a physically wired...
3
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current...
7
code green
by: code green | last post by:
I am trying to access files on a different drive but the same server to where the script is running. but I only get the error failed to open dir: Invalid argument in...
6
by: MK | last post by:
I don't use c much but i've done lots of perl, perl/Tk, and shellcode on LINUX. I'm trying to do things with directory trees and i occasionally get back an errno from opendir "No such file or...
2
by: kkhan5000 | last post by:
Hello, I would like to use an URL insttead of a local path in the following command, is it possible? $url = 'http://www.mysite.com/content/'; $dir = opendir($url); Thank you,
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.