Warning: main(): Failed opening~~~~

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Well i dont think that what i did made this problem.
I changed so i got a new header on the portal,
it worked just fine, then 5 mins later this comes up:

Code: Select all

Warning: main(http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/9.php): failed to open stream: HTTP request failed! HTTP/1.1 404 OK in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/banners.php on line 6

Warning: main(): Failed opening 'http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/9.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/banners.php on line 6
So ofcourse i changed the portals header back to standard.

But this problem is still there..

Its the random banner script we talked about before.
And as i can see it, i cant even open the file that creates it =/

http://www.volunteerforum.se/overallhea ... anners.php

Code: Select all

This code has always worked so =/



<?php
srand ((double) microtime( )*1000000);
$numbanners = 14;
$number = rand(0,$numbanners);
echo "<table align=center width=468 height=60><tr><td>";
include ("http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/$number.php");
echo "</td></tr></table>";
?>
This file has worked all the time, and i dont think it had anything
to do whit me changing the header on the portal :?

So i temporarily removed this script from the header.
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

I still don't think that include is correct, in my experiences you should never have an http link in the include.

I would go with file_get_contents() :wink:
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

But it has worked all the time like this :?

But i do use it on the:

include/page_header.php
$template->assign_vars(array("ROTATEBANNER" => file_get_contents('http://www.volunteerforum.se/overallhea ... anners.php')));
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

It should work for this particular function as well.. but if not, we will need to look for an alternative :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I tried your way in the banners.php
http://www.volunteerforum.se/overallhea ... anners.php

Code: Select all

<?php
srand ((double) microtime( )*1000000);
$numbanners = 14;
$number = rand(0,$numbanners);
echo "<table align=center width=468 height=60><tr><td>";
file_get_contents('http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/$number.php');
echo "</td></tr></table>";
?>
Then i got this instead
Warning: file_get_contents(http://www.volunteerforum.se/overallhea ... number.php): failed to open stream: HTTP request failed! HTTP/1.1 404 OK in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/banners.php on line 6
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

file_get_contents('http://www.volunteerforum.se/overallhea ... rotate_nr/' . $number . '.php');

You needed the ' . . ' around the variable $number
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Ok, fixed:

Code: Select all

Warning: file_get_contents(http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/4.php): failed to open stream: HTTP request failed! HTTP/1.1 404 OK in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/banners.php on line 6

Code: Select all

<?php
srand ((double) microtime( )*1000000);
$numbanners = 14;
$number = rand(0,$numbanners);
echo "<table align=center width=468 height=60><tr><td>";
file_get_contents('http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/' . $number . '.php');
echo "</td></tr></table>";
?>

Can it be the server that makes this problem ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Ok i made a test and included:
http://www.volunteerforum.se/overallhea ... e_nr/1.php

Code: Select all

Test.php


<?php

include("http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/1.php");

?>
http://www.volunteerforum.se/overallhea ... r/test.php

Code: Select all

Warning: main(http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/1.php): failed to open stream: HTTP request failed! HTTP/1.1 404 OK in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/test.php on line 3

Warning: main(): Failed opening 'http://www.volunteerforum.se/overallheader/RandomBanner/rotate_nr/1.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/test.php on line 3
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

This works:

Code: Select all

test.php


<?php

include("1.php");

?>


This:
http://www.volunteerforum.se/overallhea ... e_nr/1.php
or:
overallheader/RandomBanner/rotate_nr/1.php

Does not work
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Now the file works agian:
http://www.volunteerforum.se/overallhea ... anners.php

Code: Select all

<?php
srand ((double) microtime( )*1000000);
$numbanners = 14;
$number = rand(0,$numbanners);
echo "<table align=center width=468 height=60><tr><td>";
include ("$number.php");
echo "</td></tr></table>";
?>
Changed:
include ("http://www.volunteerforum.se/overallhea ... number.php");

To:
include ("$number.php");


But why ?
I haden't changed a thing, but now it works ? :?
Why did i need to make this change when it has been working before ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I added AdSence on the normal header.

And continued to work on the testpage
http://www.volunteerforum.se/testpage.php

I did get the banners.php file to work, but i cant include
it whitout problem (yet)

BTW battye, look at this nicly done site i saw today:
http://www.mountainfund.org
Really lowely site. perfect done.. :P
Best volunteer site i have seen so far
(Except mine ofcourse) :wink:
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

I simplified this test:

This should work:

test.php

Code: Select all

<?php 
include ("http://www.volunteerforum.se/overallheader/RandomBanner/Tanzaniaprojektet.jpg");
?>
But it dosen't

Code: Select all

Warning: main(http://www.volunteerforum.se/overallheader/RandomBanner/Tanzaniaprojektet.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/test.php on line 3

Warning: main(): Failed opening 'http://www.volunteerforum.se/overallheader/RandomBanner/Tanzaniaprojektet.jpg' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/volunteerforum/www/overallheader/RandomBanner/rotate_nr/test.php on line 3
Seems like there is something else then just a faulty code


But when i include something from the same folder it works.
Like: include ("1.php");

Can't it be the server in some way ?
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

With your first example, you can't include an image. You output an image with echo '<img src="linktoimage.jpg" />'; :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Leon
Know-It-All
Know-It-All
Posts: 282
Joined: Tue Feb 07, 2006 11:09 am
Contact:

Ok, that worked. But how do i include another php file then ?
(Whit a long url)

How do i include/echo this file in another php file in a proper way:
http://www.volunteerforum.se/overallhea ... e_nr/1.php

If i need i can have this in the root file too:
$template->assign_vars(array("***" => file_get_contents('*FOLDER*FILE*')));

Because it dosen't work for me anymore...
Talk, discuss or debate everything about Volunteer 'ing at this forum!
Volunteer Forum Community
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

What is the path (http://...) to the file you wish to put the code into?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Post Reply