Trying to include a function and its not working properly.
I have a Ping function thats in a file called pinger.php
Im trying to add this into a table for a form that im putting togeither.
I have tried to just put the function into my orginaly script but thats not working.
SO i tried to include it into my script still not working
How would i add the pinger.php into my table?
[code]
<table>
<tr>
<td>
<php include pinger.php; ?>
</td>
</tr>
</table>
Something like is what i would like to have. Also i want my pinger script to pull and ip from a database.
Here is my pinger.php script
[code]
<?php
function Ping(){
// false proxy used to generate connection error
$ProxyServer = $row[‘ip’];
$ProxyPort = 80;
$timeout=3;
//echo “Opening ProxyServer $ProxyServer<br>”;
// must use next two statements
Set_Time_Limit(0); //Time for script to run .. not sure how it works with 0 but you need it
Ignore_User_Abort(True); //this will force the script running at the end
$handle = fsockopen($ProxyServer, $ProxyPort,$errno,$errstr,$timeout);
if (!$handle){
echo “<img src=’images/red.jpg’><br>”;
return 0;
} else {
// copied method for PING like time operation
$status = socket_get_status($handle);
//echo “Opened ProxyServer $ProxyServer<br>”;
//Time the responce
list($usec, $sec) = explode(” “, microtime(true));
$start=(float)$usec + (float)$sec;
$timeout=120;
stream_set_timeout($handle,$timeout);
//send somthing
ini_set(‘display_errors’,’0′);
$write=fwrite($handle,”echo thisn”);
if(!$write){
return 0;
}
//echo “Try To Read<br>”;
stream_set_blocking($handle,0);
//Try to read. the server will most likely respond with a “ICMP Destination Unreachable” and end the read. But that is a responce!
fread($handle,1024);
fclose($handle);
echo “<img src=’images/green.jpg’><br>”;
ini_set(‘display_errors’,’1′);
//Work out if we got a responce and time it
list($usec, $sec) = explode(” “, microtime(true));
$laptime=((float)$usec + (float)$sec)-$start;
if($laptime>$timeout)
return 0;
//else
// $laptime = round($laptime,3);
return $laptime;
}
}
// must use ErrorHandler to avoid php error being printed to screen
function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
// you can set this to what ever you like.
//echo “In Error Handler<br>”;
return 0;
}
$old_error_handler = set_error_handler(“userErrorHandler”);
$time = Ping();
//echo “Time=n$time<br>”;
//echo “Done Checking<br>”;
?>
Thanks for help!!