Page 1 of 1

using the right slash "/"

Posted: Mon Dec 16, 2002 10:24 am
by habib
Hi, I have just set-up my PHP server/parser thanks to Firepages (http://www.firepages.com.au) and its working like a dream.

The situation....

There are 10 index pages (one for each range) and these are in a directory under the public directory. Under each directory is a sub-directory which contains a description page for each product. On everypage there is a javascript menu (this is the same on everypage).

Before, I had a different menu for each page and the links were different on each menu:

i.e
index.htm - contact us link - <a href ="contact.htm"></a>
range1.htm - contact us link - <a href ="../contact.htm></a>
product1.htm - contact us link - <a href="../../contact.htm></a>

and so on.

By changing "../" to "/" the link would always start from the root - this meant I now only need one menu and with the help of PHP, I could echo out the menu on everypage - this made sense and was easy to administer.

The problem....

When I upload the site to the hosting server the page runs fine, all the scripts run and all the images are displayed. When I try to view the page locally, I get errors. When I look at the source code for images its looking at the following path: "c:\images\pr_red_165.jpg" instead of looking at the images directory from the site root.

Any ideas how I can resolve this problem?
P.s the web host company runs linux with apache (static module)

Regards
HR

Posted: Mon Dec 16, 2002 12:06 pm
by Johnm
habib,
For starters try using $_SERVER['DOCUMENT_ROOT'] to give it the full path to the directory reguardless of which server is serving the site.

Example:

Code: Select all

<?php
include_once($_SERVER['DOCUMENT_ROOT']."/std.php");
?>
John M