why am I getting a 'failed to open stream error'
Moderator: General Moderators
-
bruceg
- Forum Contributor
- Posts: 174
- Joined: Wed Mar 16, 2005 11:07 am
- Location: Morrisville, NC
- Contact:
why am I getting a 'failed to open stream error'
when I preview my file I am getting a 'failed to open stream, so such file or directory' error for the follow code:
the code is <?php require('images/Rotating_Header/rotating-header-home.php'); ?>
the file is on the server and the directory structure is correct.
Any suggestions? New to PHP, but very familiar with ASP.
thanks,
the code is <?php require('images/Rotating_Header/rotating-header-home.php'); ?>
the file is on the server and the directory structure is correct.
Any suggestions? New to PHP, but very familiar with ASP.
thanks,
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
use realpath() on the path you are passing to the function to see where it's trying to open it. Remember that case matters 
Moved to PHP - Code.
Moved to PHP - Code.
Code: Select all
$realpath = realpath('images/Rotating_Header/rotating-header-home.php');-
bruceg
- Forum Contributor
- Posts: 174
- Joined: Wed Mar 16, 2005 11:07 am
- Location: Morrisville, NC
- Contact:
I don't think I am doing this right for an include file because it's not working. I have:
don't I still need to have the require in their somewhere?
Code: Select all
<?php
$realpath = realpath('SSI/rotating-header.htm') ;
?>is the SSI directory in the root directory of which the script resides?
if so, try this.
if so, try this.
Code: Select all
<?php $realpath = realpath('./SSI/rotating-header.htm') ;?>then the path you are trying to access the file at is incorrect. that's the only thing that could cause it not to work.
i'm assuming that the page you are trying to access is either on localhost or on a website. instead of realpath('SSI/footer.htm'); try
realpath('http://www.mysite.com/SSI/footer.htm'); cuz it sounds to me like the directory you are trying to access does not reside in the same folder that the script is in...
i'm assuming that the page you are trying to access is either on localhost or on a website. instead of realpath('SSI/footer.htm'); try
realpath('http://www.mysite.com/SSI/footer.htm'); cuz it sounds to me like the directory you are trying to access does not reside in the same folder that the script is in...
good then try :
realpath('http://localhost/SSI/footer.htm');
realpath('http://localhost/SSI/footer.htm');
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
how about.... 
Code: Select all
require( $_SERVER['DOCUMENT_ROOT'] . 'SSI/whatever.file' );-
bruceg
- Forum Contributor
- Posts: 174
- Joined: Wed Mar 16, 2005 11:07 am
- Location: Morrisville, NC
- Contact:
thanks for the assistance guys, but it does doesn't work.
<?php $realpath = realpath('http://localhost/SSI/footer.htm');?>
gets me blank space and
<?php require( $_SERVER['DOCUMENT_ROOT'] . 'SSI/footer.htm' ); ?>
gets me errors
Notice: Undefined index: DOCUMENT_ROOT in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
Warning: main(SSI/footer.htm): failed to open stream: No such file or directory in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
Fatal error: main(): Failed opening required 'SSI/footer.htm' (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
I have the document in another folder than the include file. Is this causing the problem? I would rather keep the structure the way I have it.
<?php $realpath = realpath('http://localhost/SSI/footer.htm');?>
gets me blank space and
<?php require( $_SERVER['DOCUMENT_ROOT'] . 'SSI/footer.htm' ); ?>
gets me errors
Notice: Undefined index: DOCUMENT_ROOT in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
Warning: main(SSI/footer.htm): failed to open stream: No such file or directory in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
Fatal error: main(): Failed opening required 'SSI/footer.htm' (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\Administration\Staff_Appreciation_Awards.php on line 219
I have the document in another folder than the include file. Is this causing the problem? I would rather keep the structure the way I have it.