You should also put quotes around your keys in your arrays if they're
non-numeric. For instance:
$session["logged_in"] instead of $session[logged_in]

It's good coding habit, and it sometimes will save you from some "constant"
headaches (pun intended for everyone who has run into this problem before).

- Jonathan

-----Original Message-----
From: Brad Melendy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 12:06 PM
Subject: Re: [PHP-DB] include() statement hell!

Thanks Jonathan,
Your suggestions were very helpful, especially turning on the error logging.
Here is where I'm at now:

Files in use:

My include statements in /main/page.php:

All the fuctions I call from work great, however, I have only a
single function in and it generates an error.  The error I get

Fatal error: Call to undefined function: cleansession()

Here is the file

session_register( "session" );

function cleanSession( $id, $login, $pass )
 global $session;
 $session[id] = $id;
 $session[login] = $login;
 $session[password] = $pass;
 $session[logged_in] = true;

Lastly, if I paste the above function  into page.php (without the
session_start and session_register lines) it works fine.  I've tried giving
the function a different name, changing case, all sorts of stuff.  I've
tried renaming it to userlib.php and I've opened the file directly in my
browser with the error_reporting(2039); at the top and no error messages,
yet it is as if the file never gets included.  I've tried including ONLY and pasting all the functions into page.php (to rule
out screwing things up) and still I get the error.

I am truly confounded at this point.  Thanks for any suggestions you have.
I think I am almost out of "Include Statement Hell".  ;-)


"Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
> > So, maybe this is the question.  Can you include a file from
> > /main/page.php by using a path of /includes/
> Probably not. PHP can "see" the whole filesystem, not just the area that
> limited to your account. So, when you try to include "/includes/"
> it is trying to go down to the SYSTEM root and open up a subdirectory
> includes and get the file inside it.
> If you copy the to the same directory as page.php, you should
> have to say:
>  include("");
> However, if you have this layout:
>  /your/account/dir/main/page.php
>  /your/account/dir/includes/
>  /your/account/dir/includes/
> Then page.php would have to say:
>  include("../includes/");
> Which would go back one directory, THEN into the includes subdirectory,
> then it could find
> I would definitely add:
>  error_reporting(2039);
> 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
> 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
> Subject: Re: [PHP-DB] include() statement hell!
> Thanks Jonathan,
> I'm trying to include a file /includes/ from /main/page.php.  In
> /main/page.php I use include("includes/");.  When that didn't
> 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
> changed the php.ini file to remove the reference (still trying to get it
> 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
> by using a path of /includes/
> has functions that do connections and queries to a mysql
> Even stranger yet, is that I have one other include file called
> that has authentication related session functions.  Well, that hasn't
> at all no matter what, unless I put the functions in /includes/
> 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
> can't be found.  It's all crazy to me.
> Currently, both of my include files are called directly with two lines
> include("");
> include("");
> 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/");
> include("includes/");
> 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 file because the single function that is in
> there won't work unless the function is pasted directly into
> 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
> in ASP and those can be relative so something like ../includes/
> works great.
> ...Brad

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to