Jump to content

a server status checker that works?


andrew121

Recommended Posts

I am making a website and i have this www.22salon.com/test_login/test3/client.php i have a code that looks like this

<?php
$ip = "allexser.dnsalias.net"; //put your ipaddress here
$port= "43594"; //the port number
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) //Checks the server's status (43594 = port)
{
echo "<font>Offline</font>"; //When server status is offline, output this
}
else
{
echo "<font>Online</font>"; //Else, output this
}
?> 

This code tells whether my RS private server is offline or Online but it doesnt work. it always shows offline. I know how to use this inside an html website so dont tell me that i am doing something wrong in html. All i know is that the script is wrong. all help is appreciated.

Link to comment
Share on other sites

I pasted that exact snipet and ran it on my localhost (whilst changing the port) and it stated online..

 

If I made up another port, it would state offline.

 

Which means you must have an error on your server end.

 

Good luck :)

Link to comment
Share on other sites

Have you tried just using the php, removing any HTML?

 

Run it off your webhost and set the following:

 

$ip = "localhost"; //put your ipaddress here
$port= "80"; //the port number

 

It should say online as it does for me..

 

So maybe you do have an error with your html  ;)

Link to comment
Share on other sites

Change the offline line to"

 

echo "<font>Offline: $num, $error</font>"; //When server status is offline, output this

 

That should help you understand the error. Your code is fine and works on my machine by changing to my webhost.

 

$ip = "mzproperty.co.uk"; //put your ipaddress here
$port= "80"; //the port number

 

Link to comment
Share on other sites

You need to turn error reporting on. It is likely that the fsockopen is disabled for some reason.

 

Place this at the very top of the script....

 

<?php error_reporting(E_ALL) ; ini_set('display_errors','1'); ?>

 

Also, remove the error supressor (@).

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.