SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Hybrid View

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    relative path in including

    Code:
    my INLUDED FILE
    I have the text above in http://dot.kr/x-test/myPath1/included.php


    Code:
    <?php
    include "../myPath1/included.php";
    ?>
    And I have the code above in http://dot.kr/x-test/myPath/including.php.

    The two pages produces same result because the second page include the 1st page.

    Code:
    <?php
    include "myPath/including.php" ;
    ?>
    I have the 3rd code above in http://dot.kr/x-test/mother.php

    The 3rd file successfully includes the 2nd file,
    The 2nd IN the 3rd file fails to open the 1st file and says the quote below although http://dot.kr/x-test/myPath/including.php succeeds to open the 1st file.


    Warning: include(../myPath1/included.php) [function.include]: failed to open stream: No such file or directory x-test\myPath\including.php on line 1
    What's wrong with it?

    "PHP include" doesn't support double relative path ?

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the relative path to the file in an include() must be relative to the location of the php file the include() is in.

    if you still have problems, post the actual php code in each of your php files.

    clicking any links to a php file will only display any html output from that php file and not the php code itself.

  3. #3
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kalon View Post
    if you still have problems, post the actual php code in each of your php files.
    I have 3 fils.

    The text below is all text and no code in the 1st file which is in http://http://dot.kr/x-test/myPath1/included.php .
    Code:
    my INLUDED FILE
    The code below is all code in the 2nd file which is in http://dot.kr/x-test/myPath/including.php.
    Code:
    <?php
    include "../myPath1/included.php";
    ?>
    The code below is all code in the 3rd file which is in http://dot.kr/x-test/mother.php.
    Code:
    <?php
    include "myPath/including.php" ;
    ?>

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the 3rd file, try changing

    Code:
     
    include "myPath/including.php" ;
    to

    Code:
     
    include "./myPath/including.php" ;
    btw - I normally enclose the path in () but it shouldn't matter really

  5. #5
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kalon View Post
    in the 3rd file, try changing
    Code:
     
    include "./myPath/including.php" ;
    I changed the 3rd file like the below and saved it as mother1.php.
    Code:
    <?php
    include "./myPath/including.php" ;
    ?>
    As I click the mother1.php, it produces the same Warning above.

  6. #6
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since included.php and including.php are in the same directory change

    Code:
    include "../myPath1/included.php";
    to

    Code:
     
    include "included.php";


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •