Re: Includes and paths confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, April 28, 2006 3:09 am, Nick Wilson wrote:
> nick@communicontent > ls
> ads/  config.inc  db.inc  funcs.inc  init.inc
>
> where ads/ is a whole huge set of scripts from an existing setup. ads/
> was originally placed on its own domain as it's a version of phpadsnew
> and runs as a server all by itself.

Whoever wrote phpadsnew assumed you don't understand PHP's
include_path, so they tried to be "smart" and used relative paths.

But that ONLY works if you install everything in exactly the same
structure as they thought you should. :-(

> I moved ads/ to this directory to try to troubleshoot and make things
> clearer.
>
> db.inc has these lines:
>
>
> require_once("ads/admin/config.php");
> require_once("lib-statistics.inc.php");
> require_once("lib-zones.inc.php");
> require_once("config.inc.php");
> require_once("lib-db.inc.php");
> require_once("lib-dbconfig.inc.php");
>
> warning: main(../config.inc.php): failed to open stream: No such file
> or
> directory in
> /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php
> on line 33.
>
>
> Fatal error: main(): Failed opening required '../config.inc.php'
> (include_path='.:/usr/lib/php') in
> /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php
> on line 33

So, the ads/admin/config.php is looking for '../config.inc.php' which
is not there.

But it's getting called, as far as we can tell from what you have
posted, from ads/db.inc, in which case the correct path would just be
'config.inc.php', since the base path of db.inc is /ads/ and that's
where 'config.inc.php' is...

It seems awfully odd that db.inc would require 'ads/admin/config.php'
in the first place, tell you the truth...

> So, why does this not happen when ads/ is on its own domain? I can see
> it has something to do with relative paths, but even when i try to
> work
> with chdir() i still get no joy.

I don't think chdir() affects where PHP and include_path look for
include files...

> I just can't figure out what the issue may be, so any pointers in the
> right direction would be hugely appreciated.

I think the first thing I would do would be to make sure that you
restore the code to what is on the other server.

THEN, change your include_path within /ads to be:
'.:/var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads'

AND, change your include_path within /ads/admin to be:
'.:/var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin'


Oh!
It's possible, even LIKELY, that when you copied the files over, you
"missed" copying over the .htaccess files that did this for you from
the other server -- because files named with a leading '.' are ignored
by many command line tools (tar, cp, etc) unless you specifically
include them with command flags or list them by name as filenames.

If you are just missing the .htaccess files, just copy those over, and
undo any changes you've been making to try and "fix" the problem. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux