Jump to content

[SOLVED] working out the site root


gerkintrigg

Recommended Posts

Hi. I'm trying to work out the site root so that I can use this script:

 

<?php 
// start the session 
session_start(); 
header("Cache-control: private"); //IE 6 Fix 
// Your main website URL
$url='http://www.full_address.co.uk/';

// minumum number of days to be booked by the system:
include $url.'includes/db.php';
$q="SELECT no_of_days FROM no_of_days WHERE id=1 LIMIT 1";
$sql=mysql_query($q);
$r=mysql_fetch_array($sql);
$minimum_no_of_days_booking=$r['no_of_days'];
?>

 

Problem is that I can't include the db connection script using the $url variable...

 

Any ideas how I can determine the root path?

 

I reference this include file from lots of different folders and sub-folders and really need it to be versatile enough to handle it.

Link to comment
https://forums.phpfreaks.com/topic/59628-solved-working-out-the-site-root/
Share on other sites

so HTTP_HOST is probably better as a rule then?

 

not a rule by the slightest, but if you need to get an absolute url path relative to a domain name that isn't pointing to the doc root, then $_SERVER['DOCUMENT_ROOT'] won't work for what you need. i use it on my site to create absolute url's on a site that has three separate domain aliases that point to a subfolder of my doc root. i now see that it wouldn't apply in this case - i guess i was too groggy when i posted.

 

anyway, i first discovered it in this thread:

 

http://www.phpfreaks.com/forums/index.php/topic,129379.msg541897.html#msg541897

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.