Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:32:01+00:00 2026-05-16T17:32:01+00:00

I have an auto refresh script that refreshes a page every 3 seconds. The

  • 0

I have an auto refresh script that refreshes a page every 3 seconds. The page it refreshes ha few database queries. When I get 20 or more members on my site the server crashes because of all the calls to the database. Is there another way to check for changes in the database?

//Can't Chat
$strFind="SELECT * FROM cantchat";
$result=mysql_query($strFind) or die(mysql_error());
while($row=mysql_fetch_array($result)) 
{
$id=$row['memid'];

$strsql="DELETE FROM cometchat_chatroommessages WHERE userid=\"$id\"";
$chkrow1=mysql_query($strsql,$connect) or die(mysql_error());

}


if($banned<1){
$strFind="SELECT * FROM ttourmember WHERE memberid=\"$curmemid\"";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$membername=$row['membername'];
$console=$row['system'];

# timeout - how long should it take before visitors are no longer 'online'? (in     minutes)
define ('timeout', 20);
// check if visitor is already in the table
$lastactive =time();
$strFind="SELECT COUNT(*) AS total FROM online WHERE `memberid`=\"$curmemid\"";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$imonline=$row['total'];

if ($imonline<1) {
// Insert new visitor
$strsql="INSERT INTO    online(lastactive,memberid,membername,console,ipaddress,accountactive)   VALUES(\"$lastactive\",\"$curmemid\",\"$membername\",\"$console\",\"$ip\",'Y')";
$chkrow1=mysql_query($strsql,$connect) or die(mysql_error());
$onlineid=mysql_insert_id();//copied        
} else {
// Update exisiting visitor
$strsql="UPDATE online SET     `lastactive`=\"$lastactive\",membername=\"$membername\",console=\"$console\",ipaddress=\"$i  p\" WHERE `memberid`=\"$curmemid\"";
mysql_query($strsql,$connect) or die(mysql_error());
$chkrow5=mysql_affected_rows($connect);

$strsql="UPDATE ttourmember SET `ipadd`=\"$ip\" WHERE `memberid`=\"$curmemid\"";
mysql_query($strsql,$connect) or die(mysql_error());
$chkrow5=mysql_affected_rows($connect);

}

// Remove any inactive visitors
$inactive = time()-21;

//Who's Online list
$strFind="SELECT * FROM online WHERE lastactive< $inactive AND `stay`<>'Y'";
$result=mysql_query($strFind) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
$friendid=$row['memberid'].",";

$strsql="DELETE FROM friends WHERE toid=\"$friendid\" OR fromid=\"$friendid\"";
$chkrow1=mysql_query($strsql,$connect) or die(mysql_error());

}

$strsql="DELETE FROM online WHERE lastactive < $inactive AND stay<>'Y'";
mysql_query($strsql,$connect) or die(mysql_error());
$chkrow5=mysql_affected_rows($connect);

//Can Chat
$query_chat = "SELECT * FROM online WHERE `memberid`<>\"$curmemid\" ORDER BY membername     DESC";
$chat = mysql_query($query_chat) or die(mysql_error());
$row_chat = mysql_fetch_assoc($chat);
$totalRows_chat = mysql_num_rows($chat);


//Count Pending Games
$strFind="SELECT COUNT(*) AS total FROM tgamertournament WHERE `memberid` =     \"$curmemid\" AND `pending`='Y'";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$tpgames=$row['total'];

$strFind="SELECT COUNT(*) AS total FROM tgamertournament WHERE `targetto` =   \"$curmemid\" AND `pending`='Y'";
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$topgames=$row['total'];

$pgames=$tpgames+$topgames;

//Steam Received Sent Challenge 
$query_stgames = "SELECT * FROM tgtournamentrequest WHERE `gamer`=\"$curmemid\" AND  `active`<>'D' AND `scored`<>'Y' AND `type`='S' AND `startfteam`='Y' AND `isaccepted`='N'    AND `startsteam`='N' ORDER BY tournamentid DESC LIMIT 3";
$stgames = mysql_query($query_stgames) or die(mysql_error());
$row_stgames = mysql_fetch_assoc($stgames);
$totalRows_stgames = mysql_num_rows($stgames);

//Waiting For Fteam Sent Challenge To Get Accepted
$query_wftgames = "SELECT * FROM tgtournamentrequest WHERE `fteam`=\"$curmemid\" AND `active`<>'D' AND `scored`<>'Y' AND `type`='S' AND `startfteam`='Y' AND `isaccepted`='N' AND `startsteam`='N' ORDER BY tournamentid DESC LIMIT 3";
$wftgames = mysql_query($query_wftgames) or die(mysql_error());
$row_wftgames = mysql_fetch_assoc($wftgames);
$totalRows_wftgames = mysql_num_rows($wftgames);

//List Posted Pending Games Accepted
$query_apostedgames = "SELECT * FROM tgtournamentrequest WHERE `gamer` = \"$curmemid\"        OR `fteam`=\"$curmemid\" AND `active`<>'D' AND `scored`<>'Y' AND `type`='P' ORDER BY     tournamentid DESC LIMIT 3";
$apostedgames = mysql_query($query_apostedgames) or die(mysql_error());
$row_apostedgames = mysql_fetch_assoc($apostedgames);
$totalRows_apostedgames = mysql_num_rows($apostedgames);

 //List Posted Pending Games
$query_postedgames = "SELECT * FROM tgtournamentrequest WHERE `gamer` = \"$curmemid\"   OR `fteam`=\"$curmemid\" AND `active`<>'D' AND `scored`<>'Y' AND `type`='P' ORDER BY   tournamentid DESC LIMIT 3";
$postedgames = mysql_query($query_postedgames) or die(mysql_error());
$row_postedgames = mysql_fetch_assoc($postedgames);
$totalRows_postedgames = mysql_num_rows($postedgames);

//Report Score
$query_score = "SELECT * FROM tgtournamentrequest WHERE `fteam` = \"$curmemid\" AND    `gamer`<>'0' AND `isaccepted`='Y' AND `active`='Y' AND `startfteam`='Y' AND  `startsteam`='Y' AND `scored` <>'Y' ORDER BY tournamentid DESC LIMIT 3";
$score = mysql_query($query_score) or die(mysql_error());
$row_score = mysql_fetch_assoc($score);
$totalRows_score = mysql_num_rows($score);

//Steam Pending Score
$query_pscore = "SELECT * FROM tgtournamentrequest WHERE `gamer` = \"$curmemid\" AND   `fteam`<>'0' AND `active`='Y' AND `startfteam`='Y' AND `startsteam`='Y' AND scored <>'Y' ORDER BY tournamentid DESC LIMIT 3";
$pscore = mysql_query($query_pscore) or die(mysql_error());
$row_pscore = mysql_fetch_assoc($pscore);
$totalRows_pscore = mysql_num_rows($pscore);

//Delete Games
$query_dmoline = "SELECT * FROM tgamertournament WHERE `memberid` = \"$curmemid\" AND `deleted`<>'Y' AND `scored`<>'Y' AND `accepted` <>'Y' AND `targetto`='0' AND `isactive`='Y'";
$dmoline = mysql_query($query_dmoline) or die(mysql_error());
$row_dmoline = mysql_fetch_assoc($dmoline);
$totalRows_dmoline = mysql_num_rows($dmoline);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:32:02+00:00Added an answer on May 16, 2026 at 5:32 pm

    Is there another way to check for changes in the database?

    Try show processlist in phpMyAdmin or a mysql-shell while your site is “under attack”… you should see the running queries and how long they are running. Maybe you find some heavy queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.