Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chdir working

Status
Not open for further replies.

mcvdmvs

Technical User
Sep 18, 2000
172
NL
Im having a problem with chdir.
This is a piece of my code

in a function a variable of an dir is given: $variable
the variable must be lowercase:
$variable = strtolower($variable);
then i need to go to the dir:
chdir("../../../mod_index/nieuwsbrief/".$variable);

but what i get is:
/mod_index/nieuwsbriefVariable
where Variable is the content if $variable.

It seems that PHP is first changing dir and then converting to lowercase, even if i set the conversion before changing dir.

Is it my fault or a bug?
and how do i solve this?

MiQ
mick@vandermostvanspijk.nl
currently installed: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux, apache
about to install: java, c++
 
Well, I did the following and it worked like a charm:

$maindir = "test/";
$subdir = "Test_SUB";

$variable = $maindir.$subdir;

$variable = strtolower($variable);
chdir($variable) or die("cannot change dir to ".$variable);

I created a folder called 'test' and then a sub-folder in test called 'test_sub' and it worked fine. I then tested the exception by changing test to a folder that does not exist and it gave me not only the die statement but also the PHP error.

So, I don't really know why it does not work for you.
 
I worked it out:
$dir = $DOCUMENT_ROOT."../../../mod_index/nieuwsbrief/".$variable
chdir($dir);

works, thanx MiQ
mick@nederland.net
wezine.vandermostvanspijk.nl
currently installed: html, JavaScript, dhtml, css, php, mysql, postgresql, xml, linux, apache
about to install: java, c++
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top