Page 1 of 1

Include paths

Posted: Fri Mar 17, 2006 11:09 am
by Michael_C
I believe I'm having a "path" problem. I'm altering the Advanced Poll app which has the following (partial) directory structure:
poll
. admin
. include

I'm not getting any error messages, nor any output

My first approach gave me errors - path errors in common.inc.php(in admin folder). As an example, I modified the path references in common.inc.php from:

Code: Select all

require "./include/config.inc.php";
To:

Code: Select all

$include_path = dirname(__FILE__);
if ($include_path == "/") {
    $include_path = ".";
}

require $include_path."/../include/config.inc.php";
The errors were resolved, however, this didn't provide any output

I then added the set_include_path() entry in index.php
The first 7 lines in index.php has:

Code: Select all

set_include_path('./include');
$include_path = dirname(__FILE__);
if ($include_path == "/") {
    $include_path = ".";
}
require $include_path . "/admin/common.inc.php" ;
echo("Reached index") ;
Still no output.

Is there a way to tell what has been executed, and what hasn't? like, any logging or trace facility? I know I can use echo() statements (or the like?). I imagine some of the changes in common.inc.php can be backed out since adding the set_include_path() in index.php, but would think

The index.php file I have created in "poll" folder is to display a list of all active polls, with either a "vote", or "display status" button depending on whether the user has already voted on a poll. The look of the page was to parallel the index.php in the "admin" folder.

Any and all help would be appreciated.

Michael

Posted: Fri Mar 17, 2006 11:41 am
by $var
would trying this maybe work:

include ('./include/config.inc.php');
or
include ('http://www.blablablah.com/include/config.inc.php');

Posted: Fri Mar 17, 2006 12:06 pm
by Michael_C
$var wrote:would trying this maybe work:

include ('./include/config.inc.php');
or
include ('http://www.blablablah.com/include/config.inc.php');
Thanks for the response.

The original code was

Code: Select all

require "./include/config.inc.php";
which caused errors trying to open the file stream.

By concatenating dirname(__FILE__) with include/config.ini.php it is essentially doing an absolute path equivalent to 'http://www.blablablah.com/include/config.inc.php'

Michael

Posted: Fri Mar 17, 2006 12:46 pm
by Michael_C
It wasn't a path issue. I hadn't seen code at the end of common.inc.php - I had assumed it was exclusively setting up a bunch of global arrays - it also checks if correctly logged in - if not, it exits

Michael

Posted: Fri Mar 17, 2006 5:02 pm
by feyd
Michael_C wrote:By concatenating dirname(__FILE__) with include/config.ini.php it is essentially doing an absolute path equivalent to 'http://www.blablablah.com/include/config.inc.php'
not exactly true. The path returned would be a local file system path, not a URL. So it may in fact be very different from the URL..