Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-26-2006, 12:26 PM   #1
coolegg2
Confirmed User
 
Join Date: May 2005
Posts: 210
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.
coolegg2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-26-2006, 12:40 PM   #2
bawdy
Confirmed User
 
Join Date: Feb 2002
Posts: 1,424
try
$fp = @fsockopen("localhost", $port, &$errno, &$errstr, 2);
bawdy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-26-2006, 12:48 PM   #3
coolegg2
Confirmed User
 
Join Date: May 2005
Posts: 210
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!
coolegg2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.