FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Weird "Failure to Open Stream" Error





PatTheGreat42
First off, I apologize for pasting such large chunks of code, but I think they'll come in handy.

Alright, here's my problem. I'm trying to create a website that has skins, but every time I try to open up the page (http://www.patthegreat.com/index.php, if you're interested), it spurts out the following error:

Quote:
Warning: main(skinsphp): failed to open stream: No such file or directory in /home/patthegr/public_html/index.php on line 5

Warning: main(): Failed opening 'skinsphp' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/patthegr/public_html/index.php on line 5


Now, this is the entirety of index.php:

Code:
<?php
if(isset($_COOKIE['skin']))
{include(index.inc);}
else
{include(skins.php);}
?>


What it's supposed to do is check if you have the proper cookie set, and if so, shows you the regular index page (index.inc), and if not, show you the page that lets you set a cookie for the skin. Simple, right? But it spurts out that weird error, and I'm hoping one of you guys out there can help me.

Last time I tried to fix this, it was suggested that the problem could be in the index.inc page, or the skins.php page. With this in mind, here's the code from index.inc:

Code:
<?php
$css = "skin".$_COOKIE['skin'].".css";
$quote[] = "I ate your dad.";
$quote[] = "I'd like to thank the Academy.";
$quote[] = "Thursday is nice.  It's like a mini-Friday, but with more purpose.";
$quote[] = "If pie were a fruit, it would not be an avacado.";
$quote[] = "I'm running for Chancellor.";
$quote[] = "I run a cut-rate mercenary service.";
$quote[] = "Did you know it's ".time()."?";
$quote[] = "I don't play Dungeons & Dragons.  But I thought about it.";
$quote[] = "A sense of purpose is important.  But so is cow.";
$quote[] = "The proof the Scots are the greatest race ever?  IRN-BRU.";
echo "
<html>

<head>
<title>Pat The Great, baby.</title>
<meta name=\"ICBM\" content=\"39.078468, -76.565172\">
<meta name=\"DC.title\" content=\"PatTheGreat.com - It's kinda pretty, really.\">
<link rel=\"stylesheet\" href=\"$css\" type=\"text/css\">
</head>

<body>
$quote[rand(0,9)]<br>
<!--Vive les tables-->
<table border=0 cellspacing=5 cellpadding=0>
<tr>
<td align=center valign=center>
<img src=images/new$_COOKIE['skin'].gif border=0>
</td>
<td></td>
<td align=center valign=center>
<img src=images/old$_COOKIE['skin'].gif border=0>
</td>
</tr>
<tr>
<td></td>
<td align=center valign=center>
<img src=images/ptg$_COOKIE['skin'].gif border=0>
</td>
<td></td>
</tr>
<tr>
<td align=center valign=center>
<img src=images/other$_COOKIE['skin'].gif border=0>
</td>
<td></td>
<td align=center valign=center>
<img src=images/friends$_COOKIE['skin'].gif border=0>
</td>
</tr>
<tr>
<td></td>
<td align=center valign=center>
<img src=images/skins$_COOKIE['skin'].gif border=0>
</td>
<td></td>
</tr>
</table>
<p><font size=1>&copy; PTG 2006</font>
</body>

</html>
";
?>


And here's the code from skins.php:

Code:
<?php
if($_POST['sent'] = "yups")
{
   setcookie("skin",$_POST['skin'],time()+(60*60*24*365));
   include(index.php);
}
else
{echo "
<html>

<head>
<title>Skin PatTheGreat.com</title>
</head>

<body>
<H1>Skins</H1>
PatTheGreat.com has new functionality: skins.  But because I'm a lazy bastard, you won't be able to view the site until you pick a skin.  And to pick a skin, you need cookies turned on.  To do so, however, is easy enough.  Select one of the options below simply by clicking of one of the little radio buttons, and then hit the nice big button at the bottom.  If you choose to hit the button without selecting the skin, however, you'll end up right back here, and it won't be fun.  Believe me.  It'll be like some kinda perverted, never-ending loop of doom.  And perverted, never-ending loops of doom are only fun when you like really bad Sci-Fi movies.  Anyways, hop to it.
<form action=\"skins.php\" method='POST'>
<input type=hidden name=sent value=\"yups\">
<table border=0 cellpadding=0 cellspacing=5>
<tr>
<td align=center valign=top>
<b>Plain</b>
<br><img src=images/skinplain.jpg>
<br><input type=radio name=skin value=plain>
</td>
<td align=center valign=top>
<b>Red</b>
<br><img src=images/skinred.jpg>
<br><input type=radio name=skin value=red>
</td>
<td align=center valign=top>
<b>Blue</b>
<br><img src=images/skinblue.jpg>
<br><input type=radio name=skin value=blue>
</td>
</tr>
<tr>
<td align=center valign=top>
<b>Green</b>
<br><img src=images/skingreen.jpg>
<br><input type=radio name=skin value=green>
</td>
<td align=center valign=top>
<b>Orange</b>
<br><img src=images/skinorange.jpg>
<br><input type=radio name=skin value=orange>
</td>
<td align=center valign=top>
<b>Black</b>
<br><img src=images/skinblack.jpg>
<br><input type=radio name=skin value=black>
</td>
</tr>
<tr>
<td align=center valign=center colspan=3>
<input type=submit value=\"Skin me up, Scotty.\">
</td>
</tr>
</table>
<p><font size=1>&copy; PTG 2006</font>
</body>

</html>
";}
?>


Can someone out there figure out where this error is coming from? I'm stumped. Thanks.
Atomo64
first... it is an error while trying to open the file, so the rest of the code doesn't matters, try searching on your files for 'skinsphp' since that's the file that your script is trying to open, not skins.php
Stubru Freak
Found it!

You forgot your quotes around skins.php and index.inc, and as . is the concatenation operator, it concatenates skins and php, becoming skinsphp

This file doesn't exist so that's the error.

So the solution is to place the filenames between quotes.
Atomo64
lol, didn't take a look at the code you posted, hehe
Related topics
phpBB2 Avatar Error
phpBB Error, seems to be a MYSQL DB error...
Another Error eh?
My RuneMail Script, failed to open stream: Permission denied
phpbb - what does this error msg mean?
[PHP] Weird Errors and lost files.
Problem with avatar
MySQL/PHP Error..
Error messages and php editing in a photo archive (fixed?)
i cannot open a file with fopen()
SMF forum error?
File upload error
Error with MySQL and PHP script in my CMS
PHP error page, die()
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.