php getcwd() returns wrong directory

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

php getcwd() returns wrong directory

Post by Sindarin »

My client is trying to move his website on his new server but we've come across a really weird problem.

The script is located in: e:\sites\www.domain.com\

getcwd() returns sometimes e:\sites\www.domain.com\demo\mega and sometimes C:\WINDOWS\system32\inetsrv
Both of these directories are wrong, getcwd() should return e:\sites\www.domain.com\

There seems to be something wrong also with functions like opendir, they always worked before now they seem to fail.

Some info about the server:

PHP Version 4.4.9
Windows NT 5.2 build 3790
ISAPI
Microsoft-IIS/6.0

Any ideas what might be causing this?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: php getcwd() returns wrong directory

Post by pickle »

Is that script being included by files in either of those directories? chdir() will change the current directory as well.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: php getcwd() returns wrong directory

Post by Sindarin »

No it's just an index.php listing all the files in a folder in order for the visitors to download.
Today even though getcwd doesn't work correctly the script seems to work again. *sigh*

It's so weird, the client has more than 1 sites/domains all on the same server. I used a test.php with a getcwd() to test it out and in siteA I got http://www.siteB.com/guestbook which is totally wrong.

There are 3 reasons why this could not be that the script is wrong, it's because:

We used the exact same settings as the old server,
The script worked on the old server and also worked the first days on the new one fine.
Recently we had max connection errors for mysql even though we had set the limit to unlimited and on the older server worked fine which is fishy.

On my server ( Linux ) the function getcwd always returns,
/home/www/mydomain.com or when the script is in a subfolder /home/www/mydomain.com/thesubfolder
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: php getcwd() returns wrong directory

Post by pickle »

When all else fails, reboot.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: php getcwd() returns wrong directory

Post by Sindarin »

haha, tried numerous times.
Finally it was fixed. It seems it was a problem from the high security settings the ISP had given to the root directories of the domains.
Post Reply