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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

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

Post 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">";  
        }

?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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:
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

ow ok thx anyway :D
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

to do a ping you will prolly just want to use a command line ping via the system() or passthru() function
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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..
Post Reply