SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Mar 2001
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I automatically run a PHP script on one of my webpages every 'n' seconds without any user interaction?

    I tried <meta http-equiv="refresh" content = "15">. The page refreshes but the php script is not executed again. Only if I press the reload button on the browser the script is re-executed.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Washington State
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're running linux, use Cron. Do both "man crontab" and have a look here :

    http://www.faqts.com/knowledge_base/...d/1005/fid/436
    http://schvin.net/writings/crontab.html
    http://campuscgi.princeton.edu/man?crontab

    If you're serving of windows I'm not sure what to do, task manager of some sort although I just found (never tried) this :

    http://users.erols.com/graysteel/wincron.html

  3. #3
    SitePoint Member
    Join Date
    Mar 2001
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is that the only way in Linux?

    Forgive me if I'm wrong but it seems to me that cron appears to be a task scheduler. Now if I have to refresh a html page with php script every 15 seconds then if I use crontab, it'll be like every time I'm logged on linux the page will go on refreshing and loading on Netscape. Of course I can give the entry only when I need to refresh and remove it when I don't but isn't there some php code or html code that can do the refreshing??

  4. #4
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript!

    use javascript! I think JavaScript will do what you're wanting it too... I've never heard of something like you're talking about... also, try a header info like this:

    Code:
     <meta http-equiv="expires" content="0">
     <meta http-equiv="pragma" content="no-cache">
     <meta http-equiv="cache-control" content="no-cache">
    this may make the browser reload ALL info.. just a sugestion...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  5. #5
    SitePoint Member
    Join Date
    Mar 2001
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks it worked

    Thanks. When I added your 3 lines of code to <meta http-equiv="refresh" content ="n"> the page refreshed every n seconds and the php script was re-executed every time.

  6. #6
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    not a problem... glad to be of help!

    happy for you... just a question, but why are you adding something to refresh so fast? Just wondering... it's hard on a server, and eats bandwidth... hmm...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  7. #7
    SitePoint Member
    Join Date
    Mar 2001
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reason

    The reason I want to do it is that I'm hosting a server (just to learn and experiment with database management) though not on the net. The problem was of communication between the logged user and me. So I made this simple chat program which stores submitted messages into a database and every 'n' sec the php script is re-executed to view stored messages. Since I have no problems of bandwidth (I have only one user logged in at a time) its quite fine. Of course if I were to implement this on a net server it would be perhaps quite hard on the server. Anyways even though it may be a highly questionable method to go about, its working for me.

  8. #8
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a good tutorial about writing a PHP based chat program on PHP Builder - you might get some useful tips and ideas from that:

    http://www.phpbuilder.com/columns/mhall20000621.php3

  9. #9
    SitePoint Zealot cokeman's Avatar
    Join Date
    Dec 2000
    Location
    So. California
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't it be a problem if a user were typing into a text-field for the chat when the 15 seconds came by and the page reloaded on him? Just curious

  10. #10
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's why you use frames.
    Kevin

  11. #11
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup - this is one of the very few occasions when frames really are important to functional web design

  12. #12
    SitePoint Zealot cokeman's Avatar
    Join Date
    Dec 2000
    Location
    So. California
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah -- I thought of that shortly after I posted -- I guess I just dislike frames so much that I don't even think of them as the answer!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •