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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.