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

  • SEARCH
  • Home
  • 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 7038779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:42:37+00:00 2026-05-28T01:42:37+00:00

Demo.php file <?php function write_back() { echo file_get_contents(sample.html); sleep(2); write_back(); } write_back(); ?> Resulted

  • 0

Demo.php file

<?php
function write_back()
{
  echo file_get_contents("sample.html");
  sleep(2);
  write_back();
}
write_back();
?>

Resulted me this error Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\omnama\demo.php on line 8

I was echoing back the html contents from the php script to the ajax request for every 2 seconds.

Demo.html file

function loadXMLDoc()
{
 var xmlhttp;
   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
     xmlhttp=new XMLHttpRequest();
   } 
   else
   {// code for IE6, IE5
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
xmlhttp.onreadystatechange=function()
{
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
       document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
    }
   xmlhttp.open("GET","demo.php",true);
   xmlhttp.send();
}

Let me explain what I am trying to do. I have sample.html file that keeps on updating, it may contain number of users logged in currently or the number of people available to talk , something like that.

I have used an html file because whenever a new user logs in, the html file will be updated with the user name using PHP file concepts and then these html file should be updated to all the online users.So im just updating <div id="myDiv"> tag with the response given by demo.php file

I have used HTML file because requesting MySql everytime to check if anyone logged in, will cause a serious server problem thats why i wanted to use html file.but echoing back the file contents every time is giving me these error.

I was thinking to do this. just check the last modified time of the file and if it is different from the previous one then echo its contents , is this the right way ?

Could anyone explain me how do i keep track of sample.html and update it contents to the logged in users? I need some help.Thanks

  • 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-28T01:42:37+00:00Added an answer on May 28, 2026 at 1:42 am

    There are probably a few ways to go about it and eventually I guess it comes down on how many requests/updates you are having.

    However I think to begin with you need to decide how you are going to retrieve the results you are interested in.

    • Easy solution: You could use setInterval() and have the browser perform a new XmlHttpRequest on the server (POLL) to retrieve the new list of users at certain predefined intervals

    • More complicated solution: You could establish a “web-socket” like connection between the server and the browser and PUSH down to the browser the user’s list. You could set up a comet like server, long-polling custom implementation, or a socket.io (http://http://socket.io/ – I am a huge fan) and have the server notify the listening browsers when something worth notifying occurs.

    Now to the server side:

    Personally I don’t really like your approach having to write to an html file to avoid database queries. The obvious way is to query the database for new users upon request and reply back. Are there so many users that would cause a bottleneck for the server? If so could you add more servers to it? (mysql replicated just to serve this?) You could probably speed up the queries if you added a timestamp on the requests made (i.e. tell me what has changed since XXX)

    Have you though of other alternatives? I.e. if you end up using socket.io your whole online-offline status could be handled by the socket status on the server side without anything else. (socket.io server knows which clients are connected to it).

    Another idea could be to keep the online users to a memory storage such as memcached or a redis server. So on each login/logout you update a memcached server and accordingly retrieve the results from it.

    I could probably think even more ways to go about it, if I spend more time on it. However what you need to make sure is if you actually need all these and you can’t work with a simple SQL query.

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

Sidebar

Related Questions

please take a look of this, the file demo.php is an example of the
I have the following code: <? $serverurl = $_SERVER[DOCUMENT_ROOT]; $file = $serverurl.'/demo/sample_php.php'; $newfile =
This is my phpunit test file <?php // DemoTest - test to prove the
So I'm using the ProgressBar JQuery plugin ( http://t.wits.sg/misc/jQueryProgressBar/demo.php ) to create some static
is there a demo for the FanBox? http://wiki.developers.facebook.com/index.php/Fan_Box I would like to include it
http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side
see this demo from jquery ui you have to hold down the Ctrl key
So I am using jquery.autocomplete.js, demo can be found here http://www.ajaxdaddy.com/demo-jquery-autocomplete.html I want to
I'm creating a demo that must be in html code only (no server side
I want to open a directory on linux file system using the opendir() PHP

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.