Forum Moderators: coopster

Message Too Old, No Replies

Should be a simple "include" Question!

Including one level up

         

henry0

4:10 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the whole script works fine
although if I try to include the following
by using ../
<?
include ("../include_fns.php");
?>
the file include_fns.php cannot be opened

now if using the include under this new form and of course combining all files at the same level it does fine
<?
include ("include_fns.php");
?>
this include is at the top of the index page and contains a bunch of important DB functions

the index and other pages are in a separated directory
so I need to exit the directory in order to reach that include
which is one level up with the rest of my PHP code
it is important for me to make it working from a directory that does not contain the fns.php for it allows utilising only one set of major PHP files to manage many sub sites

any worng doing in my ../?

thank you

regards
henry

hakre

6:09 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi henry0,

the '../' should do the job with include. maybe php-safemode is activated and will prevent your script using it this way, but it's only an assumption and maybe a wrong one.

what i know for shure is, that i used include that way you want to do it and it worked fine.

to get the causing error out of your script, please check which include path [de3.php.net] your script is using - is the include file located relativly (../) to any of this pathes?

then ensure that the script which includes the db-module isn't itself included and php will search at a wrong place for the include. to check out the script path, use the phpinfo() [php.net] function or the according php variable (server-specific / depending on cgi/api it's using maybe)

hope this helps and maybe you can post some more details if my posting does not help.

-hakre

henry0

6:44 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks hakre,
I have enough root power on that server and run it safe mode off

I will check the other links and report

however I am on my way to a Monday all day meeting
and cannot debug further till Tuesday

Regards

Henry

Shadi

9:20 pm on Jul 13, 2003 (gmt 0)

10+ Year Member



You should attempt to first trying it out by putting in a full server path for the include e.g.


<?php
include("/web/www/site/scripts/includes/myinclude.inc.php");
?>

hakre

9:23 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jup Shadi, that's a good practise! why have i not mentioned this .... ;) and welcome to webmasterworld [webmasterworld.com].

akogo

10:42 pm on Jul 13, 2003 (gmt 0)

10+ Year Member



henry0,

Try without the "(" or ")" symbols and use single quotes ' instead like this:

<?php include '../include_fns.php';?>

Akogo

hakre

10:43 am on Jul 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Akogo: do you think this makes a difference?

akogo

1:53 pm on Jul 14, 2003 (gmt 0)

10+ Year Member



hakre,

I think it's worth a try. On my site, the include files I use wouldn't show up until I left out the braces. I've tried '../' without the braces on my site and it worked. I also tried writing out the full path to the file I wanted to include WITH braces and that works -- but I prefer the shorthand method. Hopefully, this approach doesn't blow up the computer.

Akogo