Hi, personally, I am a noob a PHP therefor I need a little bit of php help. I would like to add a mini error for if the script cannot connect to the server.
Heres my php code (I did not script it):
This code is for getting the current song and listeners on my radio server. Now I was wondering if it was possible to change it a little bit so if the server was offline it would show a error like:
Error, the radio server is offline, please try again at a later time.
Thanks for all your help!
Heres my php code (I did not script it):
| Code: |
| <?
$open = fsockopen("IP GOES HERE","PORT GOES HERE"); if ($open) { fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n"); $read = fread($open,1000); $text = explode("content-type:text/html",$read); $text = explode(",",$text[1]); } else { $er="Connection Refused!"; } ?> </div> <? if ($text[1]==1) { $state = "Up"; } else { $state = "Down"; } if ($er) { echo $er; exit; } echo "<font face=verdana size=1> Current Song: $text[6]<BR> Listeners: $text[0] of $text[3] ($text[4] Unique) ";?> |
This code is for getting the current song and listeners on my radio server. Now I was wondering if it was possible to change it a little bit so if the server was offline it would show a error like:
Error, the radio server is offline, please try again at a later time.
Thanks for all your help!
