Page 1 of 1

I get an erro when i want to ping an ip?

Posted: Sun May 25, 2003 5:45 am
by Skywalker
Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /home/sites/site48/web/dbz/serverstatus.php on line 4

The server isn't located at my room. !! Is ther an other way to do this thing?


Code: Select all

<?php

    	$ip='222.222.222.222';  //edit: missing '
    	$port=80; 
	$fp = fsockopen ($ip, $port, &$errno, &$errstr, 30); 

        if (!$fp) { 
            echo "<font face="verdana" size=2 color="#000000"><b>Forum server is not online</b>";
			echo "<META HTTP-EQUIV="refresh" content="6;URL=$Link0">";   
        } else { 
            echo "<font face="verdana" size=2 color="#000000"><b>Forum server is online 1 moment please.</b>";
			echo "<META HTTP-EQUIV="refresh" content="6;URL=http://test/test/forum">";  
        }

?>

Posted: Sun May 25, 2003 6:01 am
by volka
$fp = fsockopen ($ip, $port, &$errno, &$errstr, 30);

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen()
it moans about &$errno and &$errstr.
try

Code: Select all

$fp = fsockopen ($ip, $port, $errno, $errstr, 30);
instead. The third and fourth parameter of fsockopen are declared as by reference anyway.

Posted: Sun May 25, 2003 8:50 am
by Stoker
just another note, it is a TCP socket that is being opened with that code and has nothing to do with ICMP ping :wink:

Posted: Mon May 26, 2003 12:38 pm
by Skywalker
ow ok thx anyway :D

Posted: Tue May 27, 2003 1:08 pm
by liljester
to do a ping you will prolly just want to use a command line ping via the system() or passthru() function

Posted: Tue May 27, 2003 1:21 pm
by Stoker
I think he achieves what he wants to do with the code above, as he verifies that the webserver is actually accepting TCP requests, an ICMP Ping wouldn't verify anything else than that the host is up..

To take it further he could verify that a GET / HTTP/1.0 returns 200 or 302 but that's really not needed for a quick up-test..