PHP rel path problems

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

madpierrot

Thread Starter
Joined
Jul 14, 2005
Messages
1
my system is running windows server 2003 IIS 6.0 using php4 (provided in the plesk 7.5 install)

if i do a statement: include("file.php"); i receive no errors
if i do: file_exists("absolutepath/file.php"); returns true
if i do: file_exists("file.php"); returns false

both the .php file that is making the function calls and "file.php" are in the same directory. it seems like php doesn't like relative paths so things like "../cfg/tables.php" and "includes/config.php" etc are invalid.

so a statement like: include("includes/config.php"); would give me an error that no such file or directory exists.

i also have a freebsd server running the same version of php and everything works fine, but my boss went behind my back and bought a windows server and decided that he would like the web app hosted there instead. i thought i could just move the code over but this pathing problem has destroyed the program. does anyone have any idea what's going on? i think it possibly could be the php.ini file but i'm not too familiar with it.
 
Joined
Feb 7, 2004
Messages
183
There isnt any chance that in your php.ini you have it pointing to the includes folder within php ?

This: require ROOT.'include/common.php';
Always works for me (as an example)

But I also use:
include(myfile.php) which is in php/includes (from my ini file)

NOT sure I helped really
 
Joined
Nov 2, 2000
Messages
637
I found the best way to do this is to setup a global config variable. I have PATH & BASE_PATH. For my use, PATH is the full path to the project folder like so:
PATH = /var/www/project1/

While BASE_PATH is something I can use before all images and such to provice a path based on the web root.
BASE_PATH = /project1/ //since this in the project1 folder of the web root /var/www

I find it makes it much easier to work around moving things and different configurations.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top