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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.