Problem: The production server and development server determine different current directories.
My development directory structure is like:
c:\inetpub\wwwroot\project\main\login.php
c:\inetpub\wwwroot\project\main\errorhandler.php
c:\inetpub\wwwroot\project\library\libone\dbconnect.php
login.php references dbconnect.php thus:
require_once('../library/libone/dbconnect.php');
in turn dbconnect.php references errorhandler.php thus:
require_once('../main/errorhandler.php');
presumably because it is still login.php that is executing, so the current directory is c:\inetpub\wwwroot\project\main.
All hunky-dory..................until I put in on the production server.
login.php references dbconnect.php ok as before.
But the reference in dbconnect.php ro errorhandler.php has to be changed to
require_once('../../main/errorhandler.php');
It seems that on the production server the current directory is determined by the source file that happens to contain the executing function, not the source file called in the first place by the web server.
All offer of clues, help and enlightenment greatfully accepted.
Simon
relative paths and require()
Moderator: General Moderators
-
simonhooper
- Forum Newbie
- Posts: 2
- Joined: Thu Sep 04, 2003 11:44 am
Normally when I do an include() from a file in another folder, all of the links inside that include file (that are include functions as well) are simply added to the path of the parent file. ie:
/page.php // Parent page
/includes/included_page.php // included file
All of the code that's inside the included_page.php is simply pasted into page.php, not executed before it's included. That's the main problem between using windows as your testing machine, and a linux box for your production machine.
Dont even get me started on my phpFF project (Controls all files and folders where placed). That was a horrible task.
/page.php // Parent page
/includes/included_page.php // included file
All of the code that's inside the included_page.php is simply pasted into page.php, not executed before it's included. That's the main problem between using windows as your testing machine, and a linux box for your production machine.
Dont even get me started on my phpFF project (Controls all files and folders where placed). That was a horrible task.
-
simonhooper
- Forum Newbie
- Posts: 2
- Joined: Thu Sep 04, 2003 11:44 am
