...

View Full Version : include problem in php



kevinkhan
09-01-2011, 04:43 PM
i am running a file in the following folder on my hosting server

/httpdocs/folder1/folder2/script.pjp

how do i include a file that is located at the root of the hosting server

/httpdocs/globalFunctions.php


iv tried


$maindir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
require $maindir . DIRECTORY_SEPARATOR . "globalFunctions.php";



include('http://www.domainname.com/globalFunctions.php');

and


include('../../globalFunctions.php');

but none of these work

any ideas

m1l
09-01-2011, 05:11 PM
Think you might need some changes on open_basedir and/or safe mode to allow this.

kevinkhan
09-01-2011, 07:57 PM
Think you might need some changes on open_basedir and/or safe mode to allow this.

can you explain abit more about this. i cant find anything on google about it :(

tangoforce
09-01-2011, 08:49 PM
include('http://www.domainname.com/globalFunctions.php');


That will never work as the server sees it as a http request and EXECUTES the PHP file. All you will see is html output NOT php code.

kevinkhan
09-01-2011, 08:52 PM
That will never work as the server sees it as a http request and EXECUTES the PHP file. All you will see is html output NOT php code.

sorry guys i got it.. was a simple mistake :(

This is what I used in the end and it worked grand


$globalFunctions = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'globalFunctions.php';

include($globalFunctions);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum