PHP Online/Offline Code Don't Work

Matthewza

Posting Freak
Apr 20, 2012
777
77
Hello Devbest,

I have made a status page for my Hotel, and it's keep saying it's offline but the Servers Online? and the ip and port are right, Something is blocking it and I don't know what?

Help Please!

is the URL
 

Exilo

Member
Apr 27, 2012
192
5
Hello Devbest,

I have made a status page for my Hotel, and it's keep saying it's offline but the Servers Online? and the ip and port are right, Something is blocking it and I don't know what?

Help Please!

is the URL
Is it hosted on webhosting?
Check the Terms of Service of the webhosting, I know many webhostings is blocking port scanning.
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
Is it hosted on webhosting?
Check the Terms of Service of the webhosting, I know many webhostings is blocking port scanning.

Nawh it's not that, I tried using my dads port to test it and it worked so it's my port but it's right?

PHP code?
PHP:
<br><head><link rel="stylesheet" href="bootstrap/css/bootstrap.css" />
<head><?php $ip = "IP";
    $port = "PORT";
    if (! $sock = @fsockopen($ip, $port, $num, $error, 5))
    echo '<span class="label label-important">Offline</span>';
    else{
        echo '<span class="label label-success">Online</span>';
        fclose($sock);
    }  ?>
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
PHP:
<?php $ip = "IP";
    $port = "PORT";
    if ($sock != @fsockopen($ip, $port, $num, $error, 5))
    echo '<span class="label label-important">Offline</span>';
    else{
        echo '<span class="label label-success">Online</span>';
        fclose($sock);
    }  ?>
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
That's working code, unlike yours.

Oh, 1 second lemme try that 

It worked but the Only problem is that I have to add
PHP:
<head><link rel="stylesheet" href="bootstrap/css/bootstrap.css" /><head>
to make it work by any chance I put it wrong? cause now it says Warning: fclose() expects parameter 1 to be resource, null given in /home/u430241350/public_html/info.php on line 8 is the link
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
Change
Code:
class="label label-important"

to

Code:
class="btn btn-danger"

and

Code:
class="label label-success"

to

Code:
class="btn btn-success"

Worked :D Thanks

Omg, I'm having trouble again with the stupid Status crap. Look I turned off the Hotel to test if it works and it doesn't? it says it's Online but really it's Offline.
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
it was probably your cache

Nawh, It wasn't I cleaned it on Google Chrome and tried it didn't work. I also even tried on Internet explorer and cleaned my Cache and still the same thing.

If you go on it says it's Online but my Server is offline? :/
 

Users who are viewing this thread

Top