what i am trying to do... is a simple script that connects to sql server, picks some info from database and posts it in small table in the website. I've faced the problem that if sql server is offline (it happens) then it timeouts in 60 secs and shows an error. By that time, website is unavailable for few minutes. What i want to do is to give timeout value from 60secs to example 2 and if it fails, to show an message like "Could not connect" The script looks like
<?php
$dbserver="[IP-ADDRESS]";
$dblogin="root";
$dbpass="[PASSWORD]";
$dbname="[DATABASENAME]";
mysql_connect($dbserver, $dblogin, $dbpass);
mysql_select_db($dbname);
mysql_query("SET NAMES 'utf8'");
$vypis = mysql_query("SELECT * FROM characters WHERE (accesslevel < '1') order by pkkills desc LIMIT 5");
echo '<table style="text-align: center; width: 220px;" border="0"><tr><td><center>Nick</center></td><td></td><td>Kills</td></tr>';
while($row = mysql_fetch_array($vypis))
{
echo '<tr><td><b><font color="white">';
echo $row["char_name"];
echo '</font></td><td> </td><td><font color="white">';
echo $row["pkkills"];
echo '</font></td></tr></b>';
echo '</table>';
?>
Any help or tip is highly appreciated.