warning: failed to open stream error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

warning: failed to open stream error

Post by bruceg »

can anyone assist me in possibilities to why my includes receive this error:

Warning: main(/web_calendar/connect.php): failed to open stream: No such file or directory in c:\inetpub\wwwroot\web_ calendar\admin.php on line 45

the file is called admin.php and resides in a folder called web_calendar which is at the root level on my site.

the include is called as such :

<?php include("/web_calendar/connect.php"); ?>

I'm using IIS instead of apache

thanks in advance,

Bruce Gilbert
Webmaster
DPS
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

post the code

Post by method_man »

post the code

matt
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

Post by bruceg »

well basicly I get an error everytime I call a file with include.

Here is code from a sample file with different ways to call the include with PHP and they all give me errors.

the includes are located within a file called SSI which is at the root level.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>include test</title>
</head>
<body>

<!--quick test by Chris Ogden for DPS  -->

This file is located in: "<b><?php echo dirname(__FILE__) ;  ?></b>"

<p><p>
absolute path (should always work): "<?php include ' c:\inetpub\wwwroot\SSI\footer.htm'; ?>"

<p><p>
separator: "<?php echo PATH_SEPARATOR; ?>"

<p><p>
include_path before: <?php echo get_include_path(); ?>

<?php set_include_path(get_include_path() .PATH_SEPARATOR.' c:\inetpub\wwwroot\SSI'); ?>

<br>
include_path after adding SSI: <?php echo get_include_path(); ?>


<p><p>
just the filename should now work: "<?php include('footer.htm'); ?>"




<p><p>
no lead slash (should only work if calling file is "above" the SSI directory):  "<?php include("SSI/footer.htm"); ?>"

<p><p>
dots (should only work if in a subdirectory at the same level as SSI): "<?php include("../SSI/footer.htm"); ?>"



</body>
</html>

thx,

-Bruce


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

include('/foo/bar.php');
is a literal path. It goes to the file system root of the server file area. So in your case including '/web_calendar/connect.php' means c:/web_calendar/connect.php
Post Reply