Link to home
Start Free TrialLog in
Avatar of Fernanditos
Fernanditos

asked on

include function and path question

Hi,

The code attached bellow is my file test.php. It works perfect if I use it inside /board/ folder.

If I move it to the root of my site (/public_html/ folder) then  get this error:


Warning: require(./includes/class_bootstrap.php) [function.require]: failed to open stream: No such file or directory in /home/eagle/public_html/board/global.php on line 15

This happens because global.php require other files that are located inside /board/includes/ ...

How can I manage this issue?
How can I make that all files required by global.php to be found inside /board/includes/ ? ...

Please help!
Thank you.
<?php
include('/home/user/public_html/board/global.php');
if($vbulletin->userinfo['userid'] > 0){
    echo '<a href="login.php?' . $session[sessionurl] . 'do=logout&amp;logouthash=' . $vbulletin->userinfo['logouthash'] . '">Logout</a>';
}
?>

Open in new window

Avatar of OnALearningCurve
OnALearningCurve

Hi Fernanditos,

Don't you just need to edit global.php to have the correct relevant paths to the files it is calling?

Mark.
Avatar of Fernanditos

ASKER

I tried but there are hundreds of requires in vbulletin. Any other idea?
Create a sub-folder in board called includes and make sure that the correct scripts are in there.

Another approach is to use ini_set and ini_get to change the include_path variable

ini_set( 'include_path', '.:/home/eagle/public_html/board/:/home/eagle/public_html/board/includes:' . ini_get('include_path') );

More at http://www.php.net/ini_set and http://www.php.net/ini_get
I solved the problem with

chdir('/home/eagle/public_html/board'); before the include, it was magic, working like a charm.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of ee_auto
ee_auto

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial