salvador2001 Posted October 31, 2006 Share Posted October 31, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/ Share on other sites More sharing options...
scliburn Posted October 31, 2006 Share Posted October 31, 2006 there are a couple ways to suppress an error. place the "@" in front of a call for one.setting error_reporting(0); at the top of your pages, or possibly writing some simple code to perform checks on connections and false hoods. Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-117418 Share on other sites More sharing options...
wildteen88 Posted October 31, 2006 Share Posted October 31, 2006 You cannot suppress the following error:fatal error: maximum time of 30 seconds exceededThat 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. Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-117440 Share on other sites More sharing options...
scliburn Posted October 31, 2006 Share Posted October 31, 2006 thanks wildteen88, i did not read his post thoroughly regarding the exact error.could he not during the loop add more time to the execution of the script?set_time_limit (30);Not that i would recommend this action if the script is not written proficiently. Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-117455 Share on other sites More sharing options...
salvador2001 Posted October 31, 2006 Author Share Posted October 31, 2006 So there isnt any solution ?All i want is that its detecting if the server is online or not, if so he has to determine if the game is played. If the server is not turned on it has to echo a message. Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-117500 Share on other sites More sharing options...
salvador2001 Posted November 2, 2006 Author Share Posted November 2, 2006 anybody ? Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-118558 Share on other sites More sharing options...
salvador2001 Posted November 2, 2006 Author Share Posted November 2, 2006 never mind.Problem solved. Quote Link to comment https://forums.phpfreaks.com/topic/25723-how-to-supress-this-error/#findComment-118637 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.