include_path ignored?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

include_path ignored?

Post by newmember »

hi

i have some troubles with include_path directive....

i'm on windows machine iwth php 4.3.5 and apache 1.3.
i have common.inc file that is used by many other files...
i tried to use custom php.ini file under script's home directory.
The file has only these lines:

Code: Select all

їPHP]

include_path=&quote;home;home/admin;&quote;
common.inc is located under "home" directory.

then i get this error:
Warning: main(common.inc): failed to open stream: No such file or directory in c:\apache\apache\users\home\admin\admin_common.inc on line 2 Fatal error: main(): Failed opening required 'common.inc' (include_path='.;c:\php4\pear') in c:\apache\apache\users\home\admin\admin_common.inc on line 2
common.inc is included inside admin_common.inc.

include_path='.;c:\php4\pear' <- this seems very odd... i tried to search files for this string, to find out where it comes from, but i couldn't find where it is being set...

it seems like my php.ini is totaly ignored.
Does anyone know what could be the problem?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

if you set the path yourself, the entry in php.ini is discarded (pretty logical) with the one you specified yourself.

however

include_path='.;c:\php4\pear'
-- means --
search "current folder"
search "c:\php4\pear"

hope this helps.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

Syranide, i understand what
include_path='.;c:\php4\pear'
means.

i simply don't understand why i get the error..
Warning: main(common.inc): failed to open stream: No such file or directory in c:\apache\apache\users\home\admin\admin_common.inc on line 2 Fatal error: main(): Failed opening required 'common.inc' (include_path='.;c:\php4\pear') in c:\apache\apache\users\home\admin\admin_common.inc on line 2
there is a standard php.ini under c:\apache\apache.
additionally i put another
php.ini under c:\apache\apache\users\home\ with these lines:

Code: Select all

&#1111;PHP] 
include_path=&quote;home;home/admin;&quote;
so i'm expecting that if i have a php file with

Code: Select all

include_once("common.inc")
in any subfolder under c:\apache\apache\users\home\ directory then php parser should find common.inc and use it...

but that doesn't happen... :?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

aha, now I see what you mean... php.ini does not work in directories, it does only load the one specificed by the system, the only thing you can do is changing it using htaccess (apache) and setting it through there.

(warning: make sure you include paths are always absolute unless you want it to not be, could easily start messing things up otherwise)
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

the php.ini file that is being used is the one that you have pointed too in your http.conf file. If your server allows .htaccess files you can try this.

Code: Select all

php_value include_path c:/apache/apache/users/home/:./:
in an .htaccess file and place the file in your home directory.

you might have to play around with the file page abit as I copied it from my linux host.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

Syranide
are you 100% sure that i can use php.ini this way?
because actually i saw someone use it this way... and it worked...
strange :?
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

first of "can't"

no I'm not 100%, but if that would work it would be extremely strange as it would pretty much allow people to do whatever they want as they are free to change any setting they desire, no mechanism for controlling that to my knowledge. and if possible, it would work for you :P

might be possible, but unlikely, if it doesn't work for you it simple doesn't so you'll have to find another way anyhow ;)
Post Reply