Include problem with root directory

Discussion in 'PHP' started by GreatQuality, Aug 16, 2010.

  1. #1
    Hey, so i have this folder named /views in this folder i have two more folders one of them are called /layouts and another /jobs. There is a file /views/layouts/staff.php and another file is in /views/jobs/index.php.
    I want to include staff.php in to my index.php file.
    I know a this super global $_SERVER['DOCUMET_ROOT'], it gives out a root path.
    So I tried this in staff.php :
    <?php include($_SERVER['DOCUMET_ROOT'].'/'.'project/views/jobs/index.php'); ?> 
    Code (markup):
    I had an error:
    Warning: include(C:/wamp/www//project/views/jobs/index.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\project\views\layouts\jobs.php on line 3 
    Warning: include() [function.include]: Failed opening 'C:/wamp/www//project/views/jobs/index.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\project\views\layouts\jobs.php on line 3
    Code (markup):
    So I assume that I must somehow change includes path, can someone help me with this little problem?
     
    Last edited: Aug 16, 2010
    GreatQuality, Aug 16, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    The problem ? I see // in between /www//project

    So simple change your line to:

    <?php include($_SERVER['DOCUMET_ROOT'].''.'project/views/jobs/index.php'); ?>
    Code (markup):
     
    MyVodaFone, Aug 16, 2010 IP
  3. GreatQuality

    GreatQuality Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No it is not the problem, actually "/" is needed on LINUX servers.
     
    GreatQuality, Aug 16, 2010 IP
  4. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #4
    What about the spelling of DOCUMENT you have DOCUMET

    This works fine for me : <?php include($_SERVER['DOCUMENT_ROOT'].'/'.'project/views/jobs/index.php'); ?>
     
    MyVodaFone, Aug 16, 2010 IP
  5. GreatQuality

    GreatQuality Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Dude Epic win! ;)
     
    GreatQuality, Aug 16, 2010 IP