Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts

    Include File Not Opening - *SOLVED*

    I have a page called test.php in public_html that has the 2nd line like so:
    PHP Code:
    require_once 'myscript.php'
    myscript.php is in a directory called include that is in the public_html directory.

    I receive this error when I run test.php:
    Code:
    Warning: require_once(myscript.php) [function.require-once]: failed to open stream: No such file or directory in /home/user/public_html/test.php on line 2
    
    Fatal error: require_once() [function.require]: Failed opening required 'myscript.php' (include_path='.:/home/user/public_html/include:./include') in /home/user/public_html/test.php on line 2
    How could I receive this error when the include_path points to the location of myscript.php since the last two of the three areas specified in the include_path point to the same location of my include file?????

    Thanks for any help.

    -Shane
    Last edited by TheShaner; 08-09-2007 at 05:09 PM.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    have you tired

    ./myscript.php

    and

    ../myscript.php
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Quote Originally Posted by timgolding View Post
    have you tired

    ./myscript.php

    and

    ../myscript.php
    The point of the include_path is so that you don't have to specify the location of your include relative to where your current running page is, thus no matter where I move my page on the server, it'll never error because it'll always find my include without changing the code.

    So, using the include_path, it should search those locations for the file. It obviously did not or it would've found it since it's in 2 of the 3 the include_path search locations.

    Your code doesn't change anything except that after searching the include_path, it'll search for it in the current directory (again) with your first suggestion and in your 2nd suggestion, it'll search for it in the directory above my public_html directory, which is outside my document root.

    -Shane

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,092
    Thanks
    2
    Thanked 322 Times in 314 Posts
    The include_path is relative to the current working directory, which is not necessary the same as the current running script.

    Also, what operating system? As the separator is different : or ; depending on operating system.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    The include_path is relative to the current working directory, which is not necessary the same as the current running script.
    Correct.

    Quote Originally Posted by CFMaBiSmAd View Post
    Also, what operating system? As the separator is different : or ; depending on operating system.
    Running Gentoo Linux and so I should be using the : separator.

    Issue is resolved though. I didn't have execute permissions on the include folder

    Thanks for trying to help both of you.

    -Shane


  •  

    Posting Permissions

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