GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Need just a bit of php help... (https://gfy.com/showthread.php?t=602528)

coolegg2 04-26-2006 12:26 PM

Need just a bit of php help...
 
I have a java-based chat service and I use a bit of php code to display the current number of chatters on my main splash page. We had an incident this morning where the java chat did not start up properly after a server reboot, and the result was that this bit of php code blared a huge error message across the page. How can I change this php code to suppress the warning/error message?
PHP Code:

Currently there are:<br><span style="font-weight: bold; font-size: 26px;">
<?
$port = 1####;
function getServerAPI( $apiCommand ) {
    global $port;
    $result = "";
    $fp = fsockopen("localhost", $port, &$errno, &$errstr, 2);
    if(!$fp) {
        echo "<!-- $errstr ($errno) -->\n";
    } else {
        fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
        $header = true;
        while(!feof($fp)) {
            $line = fgets($fp,128);
            if ( $header hahahaha false ) $result .= $line;
            if ( trim($line) hahahaha "" ) $header = false;
        }
        fclose($fp);
    }
    return $result;
}
$userCount = getServerAPI( "api.UserCount" );
$roomList = getServerAPI( "api.RoomList" );
if ($userCount < 4) { $userCount = 4; }
echo $userCount;
?>
</span><br>members chatting

The problem is the line
PHP Code:

$fp fsockopen("localhost"$port, &$errno, &$errstr2); 

If the chat is down it displays a warning message that the fsockopen failed. How can I suppress that warning message without any complicated server or php-setting changes?

Thanks in adance for any help.

bawdy 04-26-2006 12:40 PM

try
$fp = @fsockopen("localhost", $port, &$errno, &$errstr, 2);

coolegg2 04-26-2006 12:48 PM

Quote:

Originally Posted by bawdy
try
$fp = @fsockopen("localhost", $port, &$errno, &$errstr, 2);

Thanks very much Bawdy, that did the trick. Nothing gets the heart racing like seeing a php error message blaring across your main splash page in 26pt font! :Oh crap


All times are GMT -7. The time now is 03:53 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123