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 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    93
    Thanks
    12
    Thanked 1 Time in 1 Post

    Failed to open stream, no such file or directory error

    Hi,

    I am getting 2 errors that appear twice in different places on the same page.

    Warning: include(C:\Inetpub hosts\domain.com\httpdocs\HSRS\addcode.php) [function.include]: failed to open stream: Invalid argument in C:\Inetpub\vhosts\domain.com\httpdocs\folder\video.php on line 469

    Warning: include() [function.include]: Failed opening 'C:\Inetpub hosts\domain.com\httpdocs\HSRS\addcode.php' for inclusion (include_path='.;./includes;./pear') in C:\Inetpub\vhosts\domain.com\httpdocs\seasons\video.php on line 469
    This is part of the code that is causing the first group of errors:

    Code:
     
    $hm = "C:\Inetpub\vhosts\domain.com\httpdocs\HSRS";
    $hm2 = "http://domain.com/HSRS";
    include "$hm\addcode.php";
    and for the second group, simply
    Code:
    <?php include("footer.php"); ?>
    only instead of
    Warning: include(C:\Inetpub hosts\domain.com\httpdocs\HSRS\addcode.php)
    I get
    Warning: include(footer.php)
    Could someone explain these errors and maybe what I can do to fix them? PHP is not my strong point

    Thanks!

  • #2
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    file:///c:/ use that

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try changing
    PHP Code:
    $hm "C:\Inetpub\vhosts\domain.com\httpdocs\HSRS";
    $hm2 "http://domain.com/HSRS";
    include 
    "$hm\addcode.php"
    to
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT']."/HSRS";
    $hm2 "http://domain.com/HSRS";
    include 
    "$hm/addcode.php"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    New Coder
    Join Date
    Jun 2008
    Posts
    93
    Thanks
    12
    Thanked 1 Time in 1 Post
    Thanks for the replies, but still nothing

    This stopped working after I moved my site over to a different server, as far as I know, I setup the database properly....

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    as far as I know, I setup the database properly....
    Make it sure that there's no errors messages generated by the server in your javascript file.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Quote Originally Posted by millsi80 View Post
    Code:
     
    $hm = "C:\Inetpub\vhosts\domain.com\httpdocs\HSRS";
    $hm2 = "http://domain.com/HSRS";
    include "$hm\addcode.php";
    1) If you use double quotes, you need to escape all "\" in your paths. E.g. like this:
    PHP Code:
    $hm "C:\\Inetpub\\vhosts\\domain.com\\httpdocs\\HSRS";
    $hm2 "http://domain.com/HSRS";
    include 
    "$hm\\addcode.php"
    Or use single quotes:
    PHP Code:
    $hm 'C:\Inetpub\vhosts\domain.com\httpdocs\HSRS';
    $hm2 "http://domain.com/HSRS";
    include 
    $hm '\addcode.php'
    Small off-topic: please be very careful about what $hm contains. I do not see from your code where $hm comes from. So just in case: if it comes e.g. from $_GET, $_POST or $_COOKIE, it must be validated very strictly (in this case I would validate it very strictly despite it is in the path part, not file name). So that you could be sure no file injection attack against your script is possible.

    2) As to the DOCUMENT_ROOT example, it is better be used like this:
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR "HSRS";
    $hm2 "http://domain.com/HSRS";
    include(
    $hm DIRECTORY_SEPARATOR 'addcode.php'); 
    (late edit: removed echo in the code above)
    DIRECTORY_SEPARATOR would be "\" under Windows and "/" under *nix type operating systems.

    To abduraooft: Please notice that the code you have posted above
    Quote Originally Posted by abduraooft View Post
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT']."/HSRS";
    $hm2 "http://domain.com/HSRS";
    include 
    "$hm/addcode.php"
    would give $hm equal to this:
    Code:
    C:\Inetpub\vhosts\domain.com\httpdocs/HSRS
    under Windows. Since the OP has been clearly working under Windows (he has Windows paths), I think you made a typo in your post. I think you meant "\" instead of "/" before HSRS.
    Last edited by SKDevelopment; 09-15-2009 at 11:05 AM. Reason: removed echo in a piece of code which was a typo

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Since the OP has been clearly working under Windows (he has Windows paths), I think you made a typo in your post. I think you meant "\" instead of "/" before HSRS.
    Not sure what you mean, but I've an xampp under my drive G in my windows machine and for the statement
    PHP Code:
    echo $_SERVER['DOCUMENT_ROOT']; 
    I get an output like
    Code:
    G:/xampp/htdocs/mydir/mysubdir
    and I've been following that method without any issues(even when I deploy my code to a server running on a linux machine)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #8
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    I meant the following:

    The OP has been working with Windows paths like this:
    Code:
    C:\Inetpub\vhosts\domain.com\httpdocs\HSRS
    The code
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT']."/HSRS"
    would assign
    Code:
    C:\Inetpub\vhosts\domain.com\httpdocs/HSRS
    to $hm in this particular case. Not in xampp I mean but with the paths the original poster has described.

    I think you made a typo and considering his particular situation meant to use
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT'] . '\HSRS'
    instead.

    To avoid such problem with slashes, I would suggest to use
    PHP Code:
    $hm $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR "HSRS"
    which should give correct slashes under any OS.
    Last edited by SKDevelopment; 09-15-2009 at 11:08 AM.


  •  

    Tags for this Thread

    Posting Permissions

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