include error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • byteit101
    New Member
    • Mar 2009
    • 25

    include error

    I have a file that needs to include a file in the parent directory, and I am testing on a WinXP with apache, PHP, and mySQL installed, so I can test my scripts (localhost only)
    In my htdocs/teq/PHP/Ses.php I have at the top:
    Code:
    <?php 
    include_once "../PHP/Ses.php";//this is including itself once
    ?>
    and i get this error:
    Warning: include_once(../PHP/Ses.php) [function.includ e-once]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apac he2.2\htdocs\te q\PHP\Ses.php on line 2

    Warning: include_once() [function.includ e]: Failed opening '../PHP/Ses.php' for inclusion (include_path=' .;c:\php\includ es;..;C:\Progra m Files\Apache Software Foundation\Apac he2.2\htdocs') in C:\Program Files\Apache Software Foundation\Apac he2.2\htdocs\te q\PHP\Ses.php on line 2
    if I change it to "./Ses.php" same error, and ../../teq/PHP/Ses.php and ../../Ses.php and so forth, but just Ses.php works fine
    I have another file in teq/ta/Reg/register.php that includes ../../confs.php located at teq/confs.php that works with no error.

    How can I solve this without using the full path?
  • byteit101
    New Member
    • Mar 2009
    • 25

    #2
    Tried PHP/Ses.php, and it worked, even though that implies it's in a diffrent dir.
    WHY?

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Originally posted by byteit101
      Tried PHP/Ses.php, and it worked, even though that implies it's in a diffrent dir.
      WHY?
      the dot-dot (..) is a Unix/Linux-only system directory, Windows won't recognize it. The reason PHP works is because mostly that htdocs is in your PATH (see Widows Path system variable) that was added during apache install. It finds PHP then looks inside it for Ses.php (which happens to be your site's root dir)

      I hope that's correct and somewhat of an explanation for you,

      Good luck



      Dan

      Comment

      Working...