Jump to content

how to supress this error


salvador2001

Recommended Posts

Hi,

I have posted a simular question before but my problem wasnt solved yet.

This script is wachting if the server is playing or not. That part works fine, but when the host server is shutted down i get a fatal error: maximum time of 30 seconds exeeded ....
How can i supress this error, or echo a message like host not active ?

I have poor knowledge of PHP so i hope that someone can solve this for me, i would be very greatfull because this problem is keeping me buisy for at least 2,5 weeks now !

Here is the script:

[code]<?php
 
$s_port  = 12203;              // Serverport 
$s_ip    = "82.217.212.106";  // Server-IP 
$timeout = 30; 

// CONN WRITE READ [1]
$s_con  = fsockopen("udp://".$s_ip, $s_port,$errno, $errstr, $timeout); 

// $s_con == false if fsockopen failed 
if(!$s_con)     
die(msg_server('Unable to connect with fsockopen [1];; '.$errstr)); 

// fwrite return false on write error, else it return how many bytes written 
if(fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00))===FALSE)
die(msg_server('Unable to write to $_con [1]')); 

// fread return false on read error, else it return the read string 
if(($ffb = fread($s_con,4))===FALSE)     
    die(msg_server('Unable to read from $_con after write. [1]')); 

// stream_get_meta_data is same as socket_get_status 
$meta_data = stream_get_meta_data($s_con); 

if($meta_data["unread_bytes"]==0)
die(msg_server('No reply, or('.$ffb.')')); 

$beginnen = fread($s_con, $meta_data['unread_bytes']); 

fclose($s_con); 

$data = explode("\n", $beginnen); 

// Serverinfo 

// CONN WRITE READ [2] 
$s_con = fsockopen("udp://".$s_ip, $s_port,$errno, $errstr, $timeout); 

if(!$s_con)
die(msg_server('Unable to connect with fsockopen [2];; '.$errstr)); 

if(fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00))===FALSE)
die(msg_server('Unable to write to $_con [2]')); 

// reading bytes and test connection 
if(($ffb = fread($s_con,4))===FALSE)
die(msg_server('Unable to read from $_con after write. [2]')); 

$meta_data = stream_get_meta_data($s_con); 

if($meta_data["unread_bytes"] == 0)     
die(msg_server('No data, sorry. ('.$ffb.')')); 

$beginnen = fread($s_con, $meta_data['unread_bytes']); 

fclose($s_con); 

msg_server('Playing Mohaa or Spearhead');   

function msg_server($server_status,$errmsg=''){     
echo "<div align='left'>  <table width='20%' border='1' cellpadding='0' cellspacing='0' bordercolor='#465461'>    <tbody>      <tr>        <td colspan='3' style='text-align:center;font-weight:700;'>Picture here</td>      </tr>      <tr>        <td colspan='3' style='text-align:center;font-weight:700;'>Server Status</td>      </tr>      <tr>        <td style='text-align:center;font-weight:700;border-color:#2D3740;'>".$server_status."</td>        <td>Error: ".$errmsg."</td>      </tr>    </tbody>  </table>\n</div>";   
}

?> [/code]
Link to comment
Share on other sites

You cannot suppress the following error:
fatal error: maximum time of 30 seconds exceeded

That error is due to your script! Your script is taking longer than 30 seconds to execute. The only to way to make this error to go away is to extend the execution time to 60 seconds in the php.ini. However this is not recommended as a script should not take longer to execute more then 30 seconds.

Setting error_reporting to zero will not suppress this error either as its still there but not actually being shown! The script will halt with a fatal error.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.