|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
can anybody help me
Hi,
Is there any way to do some kind of automatic checking on the database and based on that result make some scripts work?For example I want to check the birthdays of members from a database table on a daily basis and if there is one, a greeting card to be send.Can the checking be done automatically.Is there a way in PHP or in mySQL ie without using the server programs like cron? Mathew |
|
#2
|
|||
|
|||
|
RE: can anybody help me
Well, if you don't mind the overhead, you can check if it's a new day on every request you get..
Or, you could create a script with set_time_limit(0) and ignore_user_abort(TRUE), which calls another script every 24 hours, but this is probably not a very robust solution.. Or, you could get a friend that can use cron to call a script on your server. |
|
#3
|
|||
|
|||
|
RE: can anybody help me
Thanks for the reply.But I want to avoid server scripts if possible.And the site is a new one so I won't have much visitors for the first two three months.So how do I do it?And is it advisable to run a php script indefinitely?
|
|
#4
|
|||
|
|||
|
RE: can anybody help me
If you have at least one hit every day, you can check the database on the first hit of the day, and call a script to process the greeting or whatever else you do on a daily basis.
Prior to use, create a text file named "daily.dat" containing only the text "1051047432" (without quotes) and store it in your web docs root. Change permissions to allow writing to this file (if necessary). Then insert this script in your index.php file: <? // Each time the page is loaded, it checks to see if the daily routine has been run: // Get the timestamp of the last execution from file: $ifile = fopen("daily.dat", "r"); $lastrun = fread($ifile,filesize("daily.dat")); fclose($ifile); // 1. Check data file to see if the daily script has been run today: $lastrundate = getdate($lastrun); $now = getdate(time()); if($lastrun["mday"] != $now["mday"]) {// 2. it's not, so: // 2.1. Run the daily script: include("yourscript.php"); // 2.2. Update the data file to indicate that script has been run (save timestamp of last run to file): $ofile=fopen("daily.dat","w"); fwrite($ofile,time()); fclose($ofile); } // 3. Continue as usual: ?> This will not work on a day when you do not get any hits, but will work on subsequent days and can be adjusted to notify you if a day was missed. Look into CRON, please? |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > can anybody help me |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|