> So, maybe this is the question.  Can you include a file from
> /main/page.php by using a path of /includes/dblib.inc?

Probably not. PHP can "see" the whole filesystem, not just the area that is
limited to your account. So, when you try to include "/includes/dblib.inc"
it is trying to go down to the SYSTEM root and open up a subdirectory called
includes and get the file dblib.inc inside it.

If you copy the dblib.inc to the same directory as page.php, you should only
have to say:
 include("dblib.inc");

However, if you have this layout:
 /your/account/dir/main/page.php
 /your/account/dir/includes/dblib.inc
 /your/account/dir/includes/userlib.inc

Then page.php would have to say:
 include("../includes/dblib.inc");

Which would go back one directory, THEN into the includes subdirectory, and
then it could find dblib.inc

I would definitely add:
 error_reporting(2039);

...to the top of your page.php code to see if you can pick up any errors.
Also, check your error log if you have one (contact your hosting company if
you're not sure). 

I would definitely try to solve this the normal way by finding the problem
with the paths rather than trying to screw with your php.ini or httpd.conf
file - otherwise you'll have a script that might not work if you ever have
to move your scripts or copy them to a development server or something.

- Jonathan

-----Original Message-----
From: Brad Melendy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 27, 2002 7:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] include() statement hell!


Thanks Jonathan,
I'm trying to include a file /includes/dblib.inc from /main/page.php.  In
/main/page.php I use include("includes/dblib.inc");.  When that didn't work,
I tried copying the file to /main/ and including it there and that didn't
work either.  Finally, I tried adding a specific path to the php.ini file
for includes_path and put the files there and that worked.  Then I went and
changed the php.ini file to remove the reference (still trying to get it to
work the way I THINK it should) and then it WORKED!  But ONLY from within
/main/.  Each time I make these changes, I am making a matching change in
the actual include() statement at the top of /main/page.php and I am
restarting apache each time I change php.ini.

So, maybe this is the question.  Can you include a file from /main/page.php
by using a path of /includes/dblib.inc?

dblib.inc has functions that do connections and queries to a mysql database.
Even stranger yet, is that I have one other include file called userlib.inc
that has authentication related session functions.  Well, that hasn't worked
at all no matter what, unless I put the functions in /includes/userlib.inc
directly into the file /main/page.php.  Once there, all the functions work
fine.  Otherwise, the only error messages I get are regarding unknown
functions being referenced, yet, I never get an error that the include files
can't be found.  It's all crazy to me.

Currently, both of my include files are called directly with two lines like:

include("dblib.inc");
include("userlib.inc");

They are both located in /main/ along side page.php which is calling them.
They both seem to work this way, but as soon as I place them in /includes/
and try to call them using:

include("includes/dblib.inc");
include("includes/userlib.inc");

I get errors saying that the functions can't be found, however, no errors
saying it can't find the include files??

Lastly, even with both include files in /main/ I still have some strange
problem with my userlib.inc file because the single function that is in
there won't work unless the function is pasted directly into /main/page.php.

I think I've made this message way too long but I appreciate your help.
I've got the page working reliably with the functions all pasted into
page.php but not while including those functions.  I just can't think of
what could be making it difference.  The functions are all the same, just
running from an include file is a problem.

Thanks again, just writing this up has helped to make more sense to me.  I
think the crux of the whole thing is the path.  I'm using to including files
in ASP and those can be relative so something like ../includes/dblib.inc
works great.

...Brad




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to