Page 1 of 2
Warning: main(): Failed opening~~~~
Posted: Fri Jul 14, 2006 3:37 pm
by Leon
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.
Posted: Fri Jul 14, 2006 4:09 pm
by battye
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()

Posted: Fri Jul 14, 2006 4:25 pm
by Leon
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')));
Posted: Fri Jul 14, 2006 4:36 pm
by battye
It should work for this particular function as well.. but if not, we will need to look for an alternative

Posted: Fri Jul 14, 2006 4:42 pm
by Leon
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
Posted: Fri Jul 14, 2006 4:43 pm
by battye
file_get_contents('
http://www.volunteerforum.se/overallhea ... rotate_nr/' . $number . '.php');
You needed the ' . . ' around the variable $number
Posted: Fri Jul 14, 2006 5:07 pm
by Leon
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 ?
Posted: Fri Jul 14, 2006 5:27 pm
by Leon
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
Posted: Fri Jul 14, 2006 5:31 pm
by Leon
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
Posted: Fri Jul 14, 2006 5:37 pm
by Leon
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 ?
Posted: Fri Jul 14, 2006 9:16 pm
by Leon
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..

Best volunteer site i have seen so far
(Except mine ofcourse)

Posted: Sat Jul 15, 2006 7:10 pm
by Leon
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 ?
Posted: Sun Jul 16, 2006 5:19 am
by battye
With your first example, you can't include an image. You output an image with
echo '<img src="linktoimage.jpg" />'; 
Posted: Sun Jul 16, 2006 12:04 pm
by Leon
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...
Posted: Sun Jul 16, 2006 12:09 pm
by battye
What is the path (http://...) to the file you wish to put the code into?