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();
?>