Script working fine on xampp

Hi just make script like noob , script working fine on xampp . But when I put real domain than it show wrong info …Like my script check website down or up its working fine on xamp . But when I upload my hosting site than it give wrong info like if I put any down site still its tell me site is running and up … but in xampp server it show correctly that site down … Any Idea …

Well, it could be hundreds of things. First, is the file saved on the server as a .php file?
If not, it will not execute the php code.
We see you display variables, but, do not show how they were created. A picture of code means very little
to us. We usually post code here.

Do you know how to view your server logs? You should look at them and see if the code threw out any errors. Depending on the server, they might be in a folder called “logs”…

honestly I am totally beginner … This is the link …
click here

Well, how are you getting the value of the variable $value?

Since you are a beginner, I guess I do not understand why you would want to know if someone else’s site
is up and running. Or, are you collecting website names? I would think that to check if a site is up that is
not your own site, you would just use file_get_contents($the_url) and see if the HTTP response was right.
To check the response codes, you would need to use a CURL routine to find out the inside HTTP return
codes to see if it is valid or not. And, since a huge number of sites forward to another page, you would
need to set the CURL’s options to follow and see what the resulting page’s return codes are.

So, again, how are you creating the variable named $value???

$host = $_POST[‘name’];

if($socket [email protected] fsockopen($host, 80, $errno, $errstr, 30)) {
	$value = 1 ;
	$value = 0 ;


Well, I ran this code from and it worked. I got this back:
HTTP/1.1 200 OK Date: Mon, 24 Aug 2020 17:33:44 GMT Server: Apache Last-Modified: Fri, 26 Apr 2013 00:28:32 GMT Accept-Ranges: bytes Content-Length: 76 Vary: Accept-Encoding Connection: close Content-Type: text/html

The code:

>     <?php
>     $fp = fsockopen("", 80, $errno, $errstr, 30);
>     if (!$fp) {
>         echo "$errstr ($errno)<br />\n";
>     } else {
>         $out = "GET / HTTP/1.1\r\n";
>         $out .= "Host:\r\n";
>         $out .= "Connection: Close\r\n\r\n";
>         fwrite($fp, $out);
>         while (!feof($fp)) {
>             echo fgets($fp, 128);
>         }
>         fclose($fp);
>     }
>     ?>

This tell me that the way you are testing for the value is incorrect. I think it is because if you set something inside an “IF” clause, it always has some sort of value. And, it may not be a “zero” “0”…
Try this change and see if it fixes it.

Thanks bro for ur reply . But now i found the problem . Script 100% ok . Problem is the host provider …when I test this script on then it gave fake info . But when i test in on than it’s work fine …

Well, you might want to look into CURL. If you use a CURL routine, it can check for fake info. Not actually in the text sent back, but, it can allow you to check the HTTP return codes. Quite often a site will redirect you to another page and if you do not “follow” the redirect, you get their fake info from the first page, not the real
info from the second page. Using sockets are tricky to get to the final redirected page. Did that make sense?

Sponsor our Newsletter | Privacy Policy | Terms of Service