Fblade1987 Posted September 9, 2008 Share Posted September 9, 2008 Hi, setting a server up and just would like to know how I can set it up so that it allows php or apache to return the errors that the script causes mine just seems to show a blank page? also in the mean time can anyone tell me what wrong with this script <?php function CheckSite ($host,$timeout) { if (fsockopen(($host, 80,null,null,$timeout)) //check site exists on port 80 return TRUE; else // else check site is open on port 8080 { if( fsockopen($host, 8080,null,null,$timeout)) return TRUE; else // if both Fail Return False return FALSE; } } $host = $_GET['host']; //grabs host from query string $timeout = $_GET['time']; //grabs timeout value if (($timeout <= 120) && ($timeout > 0) ) // if the timeout variable is below 2 mins and greater then 0. it will commence { if (CheckSite($host,$timeout)) $result = "<b style=\"color:#006600;\">All Systems Go site Connected</b>"; // shows site resolves else $result = "<b style=\"color:#FF0000;\">BOOOM!! Site Not Connected</b>";// shows site does not resolves } else // if higher show error $result = "<b style=\"color:#003366;\">Error: Timeout set too high!</b>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ping - <?php echo $host;?></title> </head> <body> <P>Ok so we done the work for you here are the results <br/> <?php echo $result;?><br/> </P> </body> </html> thanks in adavance Matt Quote Link to comment Share on other sites More sharing options...
Tenzer Posted September 9, 2008 Share Posted September 9, 2008 First off, check that PHP is running correctly on the server, if you haven't checked that already. It can be done by making a phpinfo file, which simply contains: <?php phpinfo(); ?> Regarding the missing error messages, it may also be due to display_errors is set to off in the php.ini file. You should check that as well. If that isn't the case either, then check Apache's error log. It may be due to some module behaving badly, and in that case it will be logged there. Quote Link to comment Share on other sites More sharing options...
digip Posted September 9, 2008 Share Posted September 9, 2008 As Tenzer has said, you probably have error output turned off in php.ini Also, the line if (fsockopen(($host, 80,null,null,$timeout)) look slike it has two (( where it only needs one. Not sure if this fixes it,as I get another error all togehter when I change it. Fatal error: Only variables can be passed by reference Quote Link to comment Share on other sites More sharing options...
digip Posted September 9, 2008 Share Posted September 9, 2008 I changed your script a little. Had to see what it was doing. This runs through with no errors, but not sure its getting what you want out of the script as I would add a statement at the end to tell you which of the two ports it checked to be open, 80, or 8080 so you know which one it is you want. <form id="Form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="text" name="host" size="22" /> <input type="Submit" name="Form1_Submit" value="HTTP Request" /> </form> <?php $host = $_POST['host']; //grabs host from query string echo "$host"; ?> <? //$timeout = $_GET['time']; //grabs timeout value $currenttime = time(); $timeout = (time() + 120); function CheckSite ($host,$timeout) { //if (fsockopen($host,80,null,null,$timeout)) //check site exists on port 80 <<Removed this and changed below if (fsockopen($host,80,$timeout)) //check site exists on port 80 <<Changed line return TRUE; else // else check site is open on port 8080 { if (fsockopen($host,8080,$timeout)) return TRUE; else // if both Fail Return False return FALSE; } } if (($currenttime <= $timeout) && ($timeout > 0) ) // if the timeout variable is below 2 mins and greater then 0. it will commence { if (CheckSite($host,$timeout)) $result = "<b style=\"color:#006600;\">All Systems Go site Connected</b>"; // shows site resolves else $result = "<b style=\"color:#FF0000;\">BOOOM!! Site Not Connected</b>";// shows site does not resolves } else // if higher show error $result = "<b style=\"color:#003366;\">Error: Timeout set too high!</b>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ping - <?php echo $host;?></title> </head> <body> <P>Ok so we done the work for you here are the results <br/> <?php echo $result;?><br/> </P> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.