salvador2001 Posted October 24, 2006 Share Posted October 24, 2006 Hello,I have a problem wich i cant solve because my knowledge of PHP is to little at this moment. So i hope someone can help me out with a problem and give me a clear solution.This script is working fine when the hosting pc is turned on. The script will clearly show if the game is running or not. But when the hosting pc is turned of i get a error on line 11 wich says:Fatal error: maximum execution time of 30 seconds.... on line 11.Can somebody help me with this ?Here is the script:[code]<?php$s_port = 12203; // Serverport$s_ip = "82.217.212.106"; // Server-IP$s_con = fsockopen("udp://".$s_ip, $s_port);fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00));// testen verbindings opbouwfread($s_con, 4);$status = socket_get_status($s_con);// SERVER DOWNif($status["unread_bytes"] == 0) { echo "<div align='left'> <table width='20%' border='1' cellpadding='0' cellspacing='0' bordercolor='#465461'> <tr> <td colspan='3'> <div align='center'><strong>Hier Plaatje</strong></div></td> </tr> <tr> <td colspan='3'> <div align='center'><strong>server status</strong></div></td> </tr> <tr bordercolor='#2D3740'> <td align='center'><strong>Server down</strong></td>"; die();}$beginnen = "";do{ $beginnen .= fread($s_con, 1); $status = socket_get_status($s_con);}while($status["unread_bytes"] != 0);fclose($s_con);$data = explode("\n", $beginnen);// Serverinformatie$s_con = fsockopen("udp://".$s_ip, $s_port);fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00));// bytes lezen en verbindingsopbouwfread($s_con, 4);$status = socket_get_status($s_con);if($status["unread_bytes"] == 0) { echo "no info. sorry"; die();}$beginnen = "";do{ $beginnen .= fread($s_con, 1); $status = socket_get_status($s_con);}while($status["unread_bytes"] != 0);fclose($s_con);echo"<div align='left'> <table width='20%' border='1' cellpadding='0' cellspacing='0' bordercolor='#465461'> <tr> <td colspan='3'> <div align='center'><strong>hier plaatje</strong></div></td> </tr> <tr> <td colspan='3'> <div align='center'><strong>server status</strong></div></td> </tr> <tr bordercolor='#2D3740'> <td align='center'><strong>Playing Mohaa or Spearhead</strong></td>"; ;?>[/code] Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/ Share on other sites More sharing options...
trq Posted October 24, 2006 Share Posted October 24, 2006 You could try suppressing the error, might be the best solution here. eg;[code=php:0]$status = @socket_get_status($s_con);[/code] Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-113743 Share on other sites More sharing options...
Psycho Posted October 24, 2006 Share Posted October 24, 2006 Of you could put in a conditional to display a message if the server is down:if ($status = socket_get_status($s_con)) { //Insert normal code from above} else { echo "Server is down.";} Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-113745 Share on other sites More sharing options...
salvador2001 Posted October 24, 2006 Author Share Posted October 24, 2006 I dont understand //insert normal code from above, i tried a few things but like i said, my knowledge is poor. if ($status = socket_get_status($s_con)) { fread($s_con, 4);$status = socket_get_status($s_con); } else { echo "Server is down.";} I am sure its wrong because the script doesnt work like it should. Can you be more specific please sir ? Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-113769 Share on other sites More sharing options...
salvador2001 Posted October 31, 2006 Author Share Posted October 31, 2006 can anybody help me please ? Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-117545 Share on other sites More sharing options...
Psycho Posted November 1, 2006 Share Posted November 1, 2006 "//Insert normal code from above" is a commentI meant you should include the code you had previously to do whatever process you want to accomplish. Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-117689 Share on other sites More sharing options...
salvador2001 Posted November 2, 2006 Author Share Posted November 2, 2006 Problem solved. Thank you very much ! Link to comment https://forums.phpfreaks.com/topic/24947-script-works-but/#findComment-118635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.