Forum Moderators: coopster

Message Too Old, No Replies

include() with file path

loading using file path

         

kumarsena

2:41 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



hey,

just wondering if there is a way to let the include function load a file that exists outside of the folder where the script is located.

i use the following

include 'link.inc'; wic works fine

but i would like to use something like this, but its not working,

include '../link1sub.inc';

any way aroud it?

thanks
kumar

Nick_W

2:43 pm on Nov 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What error do you get? - Might have somthing to do with your include_path setting..?

Nick

kumarsena

2:51 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



this is the warning i get..

Warning: Failed opening '../link1sub.inc' for inclusion (include_path='.:/usr/local/lib/php') in /mnt/home2/k/ku/kumar/public_html/ph_album/dipbday.php3 on line 63

Nick_W

2:57 pm on Nov 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Call this (or change the setting in php.ini):
ini_set('include_path',.'/path/to/includes/');

Then put all your includes in that dir and call like this [code]include('file.inc') or include('folder/file.inc');

There may be a better way, but that would surely do it..

Nick

kumarsena

3:00 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



thanks,

looks logical
got to run, but willpost back on whter it workde or not

thanks again
kumar

NickCoons

11:08 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



kumarsena,

Also.. make sure the web server has permissions to read the include file where it's located.