Well, I assume you are using an included config file of some sort, so typically, what I do is something like this in it:
if($_SERVER['HTTP_HOST'] == "localhost") {
$root_path = "http://localhost/";
$db_host = "localhost";
$db_user = "********";
$db_password = "********";
$database = "my_local_db";
} else {
$root_path = "http://www.mydomain.com/";
$db_host = "localhost";
$db_user = "********";
$db_password = "********";
$database = "my_production_db";
}
Then, anytime I need to define a path, I use that $root_path variable. This way, I am always using absolute paths, and it doesn't matter if it's on my local machine, or production server. You can get more detailed, so you can use more than one production server, but this gives you an idea...
echo "<a href=\"".$root_path."/this_file.php\">Link</a>";