473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

timer in php script

How can I run a script based on timer / counter ? What I am trying to
do is, every 5 minutes, I want a php script to execute that searches my
database and popup a small window if the search conditions are met. I
am pretty new to php programming.
It would be great, if anybody can help me with this.

Thanks

Jul 17 '05 #1
6 7899
In article <11**********************@f14g2000cwb.googlegroups .com>,
"Perl rookie" <an******@gmail.com> wrote:
How can I run a script based on timer / counter ? What I am trying to
do is, every 5 minutes, I want a php script to execute that searches my
database and popup a small window if the search conditions are met. I
am pretty new to php programming.
It would be great, if anybody can help me with this.


You can put a "refresh" <META> tag in the header so that it re-submits
it after 5 minutes.

http://webdesign.about.com/cs/metatags/a/aa080300a.htm
http://www.htmlhelp.com/reference/html40/head/meta.html

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #2
or a chron job
<Michael Vilain <vi****@spamcop.net>> wrote in message
news:vi**************************@news.giganews.co m...
In article <11**********************@f14g2000cwb.googlegroups .com>,
"Perl rookie" <an******@gmail.com> wrote:
How can I run a script based on timer / counter ? What I am trying to
do is, every 5 minutes, I want a php script to execute that searches my
database and popup a small window if the search conditions are met. I
am pretty new to php programming.
It would be great, if anybody can help me with this.


You can put a "refresh" <META> tag in the header so that it re-submits
it after 5 minutes.

http://webdesign.about.com/cs/metatags/a/aa080300a.htm
http://www.htmlhelp.com/reference/html40/head/meta.html

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #3
Perl rookie wrote:
How can I run a script based on timer / counter ? What I am trying to
do is, every 5 minutes, I want a php script to execute that searches
my database and popup a small window if the search conditions are
met. I am pretty new to php programming.
It would be great, if anybody can help me with this.

Thanks


As is said by others, use cron on Linux, or 'at' in win32 in combination
with the commandline interface or create a script like this and run that in
a browser if you are serving from a host that does not offer cron jobs. Be
aware set_time_limit (0 is NOT allowed by all hosts, requires safe_mode off,
if safe_mode is enabled it will be ignored by PHP :

<?PHP
set_time_limit (0); // ensure the script keeps running and does not time
out.
$i = 0;
while (TRUE) {
$i++;
echo "Run $i times<br>";
ob_flush(); // use both ob_flush and flush to ensure
flush(); // output is written to the browser window
sleep(300); // 5 min interval
}
?>

I don't know if the browser creates its own time-out after a given amount
time, if that's the case it will probably be the same issue for whichever
solution you pick. Perhaps you could also use JavaScript to initiate the
process from the client side.

HTH
Pjotr
Jul 17 '05 #4
Pjotr Wedersteers wrote:
Perl rookie wrote:
How can I run a script based on timer / counter ? What I am trying
to do is, every 5 minutes, I want a php script to execute that
searches my database and popup a small window if the search
conditions are met. I am pretty new to php programming.
It would be great, if anybody can help me with this.

Thanks


As is said by others, use cron on Linux, or 'at' in win32 in
combination with the commandline interface or create a script like
this and run that in a browser if you are serving from a host that
does not offer cron jobs. Be aware set_time_limit (0 is NOT allowed
by all hosts, requires safe_mode off, if safe_mode is enabled it will
be ignored by PHP :
<?PHP
set_time_limit (0); // ensure the script keeps running and does not
time out.
$i = 0;
while (TRUE) {
$i++;
echo "Run $i times<br>";
ob_flush(); // use both ob_flush and flush to ensure
flush(); // output is written to the browser window
sleep(300); // 5 min interval
}


I don't know if the browser creates its own time-out after a given
amount time, if that's the case it will probably be the same issue
for whichever solution you pick. Perhaps you could also use
JavaScript to initiate the process from the client side.

HTH
Pjotr


Add to this equation Apache/IIS have their own time-out values as well. So
this may not be a solid route in all cases...
Jul 17 '05 #5
hmm..may be i missed to mention one thing. I have web application,
once the user logins in, I want to spawn a php app that will run in the
background as along as the user logged in. This app needs to check the
database once every say 5mins and popup a small window when a certain
criteria is met. The refresh method might work, but that means, I
need to pop a new window and have it always be open.

AHIA

Jul 17 '05 #6

newbie programmer wrote:
hmm..may be i missed to mention one thing. I have web application,
once the user logins in, I want to spawn a php app that will run in the background as along as the user logged in. This app needs to check the database once every say 5mins and popup a small window when a certain criteria is met. The refresh method might work, but that means, I
need to pop a new window and have it always be open.


Yes, you are missing the fact that PHP runs on the SERVER and can not
open windows on the client's machine. Something on the client side
needs to open the window.

Ken Robinson

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Joe | last post by:
Hi, I am trying to alter the refresh rate of an online webpage in a webbrowser control using MFC. However the Timer ID is stored in a local variable and I don't know how to access it. Is there a...
19
by: arunkumar_m2001 | last post by:
Can Somebody help me to code a timed test. Actually I want to implement a timer in a web application which will pop-up an alert automatically by refreshing the web page after a specific time. ...
1
by: jmgro | last post by:
I have spent way too much time trying to solve the following problem: I have a datalist with a timer in the footer template. It works wonderfully except when the user pages back, then forward,...
10
by: Ryan | last post by:
I'm creating a website that monitors the status of servers using My.Computer.Network.Ping. I'm looking for a way to fire off my Ping() function every second or so. I see a Timer control...
2
by: HeroinNO.4 | last post by:
Copy the code below and save in a .htm file, for example : 1.htm, then run it in browser, you'll see a cool count down timer ! If it doesn't work, you may open http://www.fillweb.com in IE and...
1
by: HeroinNO.4 | last post by:
You can open http://www.fillweb.com in IE and View->Source to see the latest version full featured count down timer source code, or you may also copy the code below and save in a "*.htm" file, for...
2
by: HeroinNO.4 | last post by:
Hello everyone! Now the latest version of free count down timer source code is available in http://www.fillweb.com/countdown.htm, you can open it in IE and View->Source to see the latest version...
7
by: HeroinNO.4 | last post by:
Hello guys, free count down timer source code has updated to 06/11/27, you can copy the code below and save in a ".htm" file and run it in a browser support javascript 1.1 or later, or you can open...
0
by: hzq3554055 | last post by:
i am novice,guess the following code can work combineing with server- side code ,but chaos ï¼›somewhere to me is great<script> var relationObject = {timer: null, key: ""}; function...
3
missshaikh
by: missshaikh | last post by:
Hi all, i need the count down timer when button click the timer start and count down work on ASP.net :( i have one timer which is on JavaScript that run page onload . but i need the Button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.