CHDir and require...not seeming to work

Discussion in 'PHP' started by blueparukia, Jan 22, 2008.

  1. #1
    Warning: require(./settings.php) [function.require]: failed to open stream: No such file or directory in W:\www\proxy\themes\Theme2\file.php on line 4

    I have double checked and the files do exist.

    Here is the file structure:
    domain_root/proxy/themes/theme2/file.php.

    In file.php I have:
    
    <?
    chdir('../../');
    require('./google.php');
    require('./settings.php');
    require('./style.php');
    chdir('./');
    ?>
    
    PHP:
    And I get that error, can I not set ../../ as the current directory?

    All three of those file are in the "proxy" directory.

    Thanks,
    BP
     
    blueparukia, Jan 22, 2008 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    chdir has nothing to do with with the require functions as far as I'm aware. You need to add the '../../' to before each of the files you are trying to include in.
     
    TwistMyArm, Jan 22, 2008 IP
  3. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #3
    No, you can't do that with including and requiring, closest thing to that is using $_SERVER['DOCUMENT_ROOT'] and using the direct path, but that doesn't work on http:// most of the time.
     
    blueparukia, Jan 22, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Try:
    
    chdir('domain_root/proxy/');
    
    PHP:
    Also, try requiring the files without the ./ in front. I remember having problems with that once too.
     
    nico_swd, Jan 23, 2008 IP