Jump to content

Timeout


assimilated

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.