FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Absolute paths using $server





D'Artagnan
Code:

<?php
$server = "http://" . $_SERVER["SERVER_NAME"]."/pagely";
require_once("$server/pagely_function.php");
?>


Call to undefined function: getpagetitle() in http:\\localhost\easyphp1-8\www\pagely\pagely_dir.php on line 11

the code cant find the functions under pagely_function.php...
MrBlueSky
This code looks for "http://www.site.com/pagely/pagely/pagely_function.php". Shouldn't that be "http://www.site.com/pagely/pagely_function.php"?

Like this:

Code:

<?php
$server = "http://" . $_SERVER["SERVER_NAME"];
require_once("$server/pagely/pagely_function.php");
?>
D'Artagnan
MrBlueSky wrote:
This code looks for "http://www.site.com/pagely/pagely/pagely_function.php". Shouldn't that be "http://www.site.com/pagely/pagely_function.php"?

Like this:

Code:

<?php
$server = "http://" . $_SERVER["SERVER_NAME"];
require_once("$server/pagely/pagely_function.php");
?>


sure, but it was my mistake ive paste a old copy....

Anyway the server can find the script, otherwise it should drop a "file not found" exception , the issue here is that PHP cant find the getpagetitle() or any other inside the file ^^
sonam
You have similar solution for absolute path but maybe little bit shorter:

It is:
Code:
$server = $_SERVER["DOC_ROOT"];


but if you need for include, require, etc. then is better to use
Code:
$server = $_SERVER["DOCUMENT_ROOT"];


First one going to your root folder via HTTP, second one is going there directly.

Code:
require_once("$server/pagely/pagely_function.php");


Sonam
Related topics
Absolute path on server...
PHP and relative/absolute paths
So, you are lazy to download a FTP program eh?
writing COM components in Perl
[PHP] mod_rewrite
Why won't my page find the stylesheet and images?
hosting my website from home????
Have Notepad In Send To
Best OS of the year
How to make a symlink
Can l get a css document to
do you know is it possoible to hide view source menu?
different types of websites
Flash
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.