assimilated Posted May 23, 2011 Share Posted May 23, 2011 So i have this script that connects to a game data base and it must select and make a top of some columns in data base. The thing is if the data base is offline then the script kinda blocks the website because it has no timeout option. How can i add like a $timeout=2 (in seconds) thing..so if after 2 seconds it gets no connection the script is killed Thanks in advance <?php $database_info = array( 'host' => '___', 'user' => '___', 'password' => '___', 'l2jdb' => '___' ); @mysql_connect($database_info['host'], $database_info['user'], $database_info['password']) or die(mysql_error()); @mysql_select_db($database_info['l2jdb']) or die(mysql_error()); echo "<table class=\"pvp\">"; $query = "SELECT * FROM characters WHERE accesslevel = 0 ORDER BY pvpkills DESC limit 10"; //change 10 to whatever amount you want to show on your website. $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $name = $row['char_name']; $pvpscore = $row['pvpkills']; // Inserting data into the table echo " <tr> <td width=\"110\"><strong> $name</strong></td> <td width=\"50\"><div align=\"center\">$pvpscore</div></td> </tr>"; } echo "</table>"; //closing mysql connection mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/237211-timeout/ Share on other sites More sharing options...
fugix Posted May 23, 2011 Share Posted May 23, 2011 you might be looking for set_time_limit() function Link to comment https://forums.phpfreaks.com/topic/237211-timeout/#findComment-1219045 Share on other sites More sharing options...
assimilated Posted May 23, 2011 Author Share Posted May 23, 2011 So all I have to do is add set_time_limit(2) at top? Link to comment https://forums.phpfreaks.com/topic/237211-timeout/#findComment-1219048 Share on other sites More sharing options...
fugix Posted May 23, 2011 Share Posted May 23, 2011 yes Link to comment https://forums.phpfreaks.com/topic/237211-timeout/#findComment-1219049 Share on other sites More sharing options...
assimilated Posted May 23, 2011 Author Share Posted May 23, 2011 well that was simple thanks Link to comment https://forums.phpfreaks.com/topic/237211-timeout/#findComment-1219051 Share on other sites More sharing options...
fugix Posted May 23, 2011 Share Posted May 23, 2011 well that was simple thanks no problem, mark as solved please, Link to comment https://forums.phpfreaks.com/topic/237211-timeout/#findComment-1219052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.