I use this $path in my Hostgator Shared Hosting accounts and it works perfectly:
$path = dirname($_SERVER["DOCUMENT_ROOT"]).'/';
I.e. this path is /home/username/public_html/
Here's an example of how I use it:
<?php
$path = dirname($_SERVER["DOCUMENT_ROOT"]).'/';
include($path.'stats.php');
?>
My problem is that this $path doesn't work in my new Hostgator Reseller account.
Does anyone know why this doesn't work for Reseller hosting and what $path I can use instead?
Ideally I'd then use an "if else" so that I could use the same code on my Shared and Reseller accounts.
Would the following work:
<?php
if(strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===false) {
// for reseller accounts
$path = WHATEVER_THE_RESELLER_PATH_IS;
}
else {
// for shared hosting accounts
$path = dirname($_SERVER["DOCUMENT_ROOT"]).'/';
}
include($path.'stats.php');
?>
I got the above "if" from here: PHP strange DOCUMENT_ROOT.