Page 1 of 1

2 problems with paths.

Posted: Thu Apr 15, 2004 5:07 pm
by a_marko
Hi,

I have two really trivial sounding problems with paths. I am constructing a site on my Windows box with Minixampp (i.e. Apache) which I then move to my ISP (Unix with Apache). On some pages I'd like to use paths that are relative to my html root directory, e.g /Navigation/TreeMenu.php.

I have Images directory for images and TreeMenu directory for navigation menus.

I'm using the following looking code in practically all pages to set up the navigation, background, banner etc.

Code: Select all

<script src="/Navigation/TreeMenu.js" language="JavaScript" type="text/javascript"> </script>
<link href="/Navigation/TreeMenuMyStyle.css" rel="stylesheet" type="text/css">
<body background="/Images/GrayBackground.jpg">
<img border="0" src="/Images/MyBanner.jpg" width="790" height="92">

<?php require_once( '/Navigation/TreeMenuMySite.php' ); ?>
1) This works halfway on the windows box. It will load the images but the PHP require will fail. Why such different behaviour regarding the path in PHP? The HTML portion did find and load the .js and .css with similar path specifications!

2) On the Unix this doesn't work at all. I know the reason for it is that on my machine $_SERVER['DOCUMENT_ROOT'] gives e:\minixampp\htdocs which is the root of my web pages, whereas on the Unix it gives something like /opt/apache/htdocs which isn't my personal html root. How should I set the paths so that filenames e.g. /Images/MyBanner.jpg would work both on my local machine and on the ISP??

Thanks for any assistance!
- Marko

P.S Cheers to the TreeMenu(XL) authors!

Posted: Thu Apr 15, 2004 5:17 pm
by markl999
require/include both use the include_path to search for the file to include. So check the include_paths on both servers, a <?php echo ini_get('include_path'); ?> will show you the paths it's searching.

Posted: Thu Apr 15, 2004 5:50 pm
by Unipus
PHP doesn't seem to recognize root ('/') in pathing. change it to

Code: Select all

<?php require_once( 'Navigation/TreeMenuMySite.php' ); ?>
and that will solve one of your problems. Although if anyone knows how to make PHP recognize root, that would be really good to know.

Posted: Thu Apr 15, 2004 8:27 pm
by d3ad1ysp0rk
./ i believe.

Posted: Thu Apr 15, 2004 10:13 pm
by John Cartwright
LiLpunkSkateR wrote:./ i believe.
correct.