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


fopen fail





Josso
Code:
     <?php
    $url = 'http://josso.dyndns.org:8000';
    $handle = @fopen($url,'r');
    if($handle !== false){
       echo '<b>Stream Status: <font color="green">ONLINE</font></b>';
    }  else {
       echo '<b>Stream Status: <font color="red">OFFLINE</font></b>'; }
      ?>


Firstly let me point out that I am totally noobed up with PHP.

Right this works, just the problem is when the stream is offline you can't just go straight to that URL and get a 404 or whatever straight away, there's like the waiting zone of ERRR IS IT OFFLINE? IS ITTT? Guessing there might be no solution as that's just a network issue as far as I can see (unless I can define when to timeout?) so if that's the case I don't mind the wait so long as I can put in a message that loads before it gets stuck on this code saying "LOADING..." or something. How do I get a message to load before this stuff?
jmraker
I've never used the function it seems like the example for stream_set_timeout page.

http://us3.php.net/manual/en/function.stream-set-timeout.php

If you're offline there is no 404/etc page because the web server returns those numbers in a response
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Josso
Nice that's definitely the command I was looking for, sorry for being such a noob but how exactly would I implement that?
saberlivre
I think If you suppress the "@" in @fopen then a E_WARNING will be generated and you can handle that.
ogah
I prefer to use curl than fopen
saberlivre
ogah wrote:
I prefer to use curl than fopen


Surely, it is better to use curl

Applause
mahirh
saberlivre wrote:
ogah wrote:
I prefer to use curl than fopen


Surely, it is better to use curl

Applause

sadly some hosts does not support it
Josso
Hey whats that document name you put up onto the server to show all the PHP info? (note: not using frihost) - that will show if curl is useable? I realise I could Google this but I've tried... I've tried stream_set_timeout and multiple other tactics I'm guessing I am just not implementing this right I don't know enough about PHP. Is there a way of just if the portion of code hangs for more than a second it's an auto FALSE, because it's not going to take more than a second to connect if the stream is up... I just need almost like a timeout for the whole script. Thanks.
Fire Boar
Do you mean the phpinfo() function? Just create a PHP script containing just that function and it'll dump info about the PHP installation, including for example whether curl is installed.
Josso
Yeah that's the one thanks
Related topics
Why is fopen-functions disabled?
fopen() gives a file with UID of apache?
PHP fopen
Open, Write to and Close a txt file using php
How do i execute an sql file in a php script?
Form Mail help........lol
PHP Member System (using FOPEN)..
i cannot open a file with fopen()
PHP Form Question
PHP: fopen('./directory/$variable'); Problem
fopen in server frihost?
News script
r+ on fopen doesn't work
Republican strategy, via Limbaugh: Wanting Obama to fail
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.