| View previous topic :: View next topic |
| Author |
Message |
isurkov
Joined: 04 Feb 2007 Posts: 3
|
Posted: Sun Feb 04, 2007 2:09 pm Post subject: Net_Ping checkHost didn't work.. |
|
|
Please give me some example of using the checkHost function in Net_Ping package , to check some host. I tried many ways, but many errors occurs.  |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Sun Feb 04, 2007 5:21 pm Post subject: Re: Net_Ping checkHost didn't work.. |
|
|
| isurkov wrote: | Please give me some example of using the checkHost function in Net_Ping package , to check some host. I tried many ways, but many errors occurs.  |
I don't have an example and also haven't used that package. But if you show us your code and tell us what error messages you get, we might be able to help you anyway. |
|
| Back to top |
|
 |
isurkov
Joined: 04 Feb 2007 Posts: 3
|
Posted: Sun Feb 04, 2007 8:08 pm Post subject: |
|
|
Code is:
| Code: |
<?php
set_include_path('c:/Servers/php5/pear');
require 'Net/Ping.php';
$ping = new Net_ping;
if($ping->checkHost('www.yahoo.com'))
{print 'Reachable';}
else
{print 'Unreachable';}
$data = $ping->ping('www.yahoo.com');
?>
|
and i get an errors:
| Quote: |
Warning: Missing argument 1 for Net_Ping::Net_Ping(), called in C:\Servers\HTTP\Apache\Apache2\htdocs\test\ping_test.php on line 12 and defined in c:\Servers\php5\PEAR\Net\Ping.php on line 135
Warning: Missing argument 2 for Net_Ping::Net_Ping(), called in C:\Servers\HTTP\Apache\Apache2\htdocs\test\ping_test.php on line 12 and defined in c:\Servers\php5\PEAR\Net\Ping.php on line 135
Unreachable
|
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
|
| Back to top |
|
 |
isurkov
Joined: 04 Feb 2007 Posts: 3
|
Posted: Sun Feb 04, 2007 9:37 pm Post subject: |
|
|
i knew it! And i allready tried to add parameters. For example:
| Code: |
<?php
require 'Net/Ping.php';
$ping = Net_Ping::factory();
if($ping->checkHost('www.yahoo.com'))
{print 'Reachable';}
else
{print 'Unreachable';}
$data = $ping->ping('www.yahoo.com');
?>
|
And i get another error:
| Quote: |
Fatal error: Cannot use object of type Net_Ping_Result as array in C:\Servers\php5\PEAR\Net\Ping.php on line 385
|
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Sun Feb 04, 2007 9:53 pm Post subject: |
|
|
This seems to be a bug in Net_Ping, your code looks right.
checkHost() calls internally ping() which returns an object, but checkHost() assumes then later that it gets an array from ping().
You can report a bug here on (*), but the package seems to be unmaintained, as there are many open and very old bug reports. If you're interested, you could take over the package, of course.
(*) http://pear.php.net/package/Net_Ping |
|
| Back to top |
|
 |
|