Reply
Demos in PHP that refresh every hour
Old 09-29-2009, 09:19 PM Demos in PHP that refresh every hour
Lashtal's Avatar
PHP Learner

Posts: 492
Name: Lashtal
Trades: 0
We've all seen at one time or another, demos for scripts written in PHP who's database refreshes every hour or so. (i.e. to prevent spammers, and to clear their sites for each amount of users that come through)

How would you go about setting up an automated command to refresh your database's tables every 60min. ?
Lashtal is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 09-29-2009, 11:12 PM Re: Demos in PHP that refresh every hour
Lashtal's Avatar
PHP Learner

Posts: 492
Name: Lashtal
Trades: 0
obviously w/cron jobs, but for anyone completely unfamiliar with crons; some direction please?
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 09-30-2009, 06:14 PM Re: Demos in PHP that refresh every hour
Lashtal's Avatar
PHP Learner

Posts: 492
Name: Lashtal
Trades: 0
Okay, I think I figured out the theory on this...

a) create a script that does "DROP TABLE IF EXISTS `tablename`" then "CREATE TABLE `tablename`" with all it's values.

b) then set script to run at the appointed interval through Cron
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 09-30-2009, 09:55 PM Re: Demos in PHP that refresh every hour
orionoreo's Avatar
Ultra Talker

Posts: 261
Name: Jerry
Trades: 0
you don't need to drop and recreate... just set to TRUNCATE TABLE 'table name' and set cron to 0 */1 * * *
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 10-01-2009, 07:07 PM Re: Demos in PHP that refresh every hour
Lashtal's Avatar
PHP Learner

Posts: 492
Name: Lashtal
Trades: 0
AHA...

thank you
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 10-17-2009, 12:52 AM Re: Demos in PHP that refresh every hour
rednimaT's Avatar
Skilled Talker

Posts: 65
Name: Taminder B.
Location: San Jose, CA
Trades: 0
do you want the user in the demo to have full functionality?

if not, an easier method would be to remove editing the MySQL queries from your script and have it display your default values.
__________________
NRG Lab - Web Design Services & Resources
(HTML/PHP/MySQL/JavaScript/AJAX/SEO)

Last edited by rednimaT; 10-17-2009 at 12:53 AM..
rednimaT is offline
Reply With Quote
View Public Profile Visit rednimaT's homepage!
 
Old 10-17-2009, 07:29 AM Re: Demos in PHP that refresh every hour
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
Actually there is no need to use a "cron job" at all for something so simple.

Simply check the time when a page is opened and if more than one hour has elapsed run a query to purge the entries.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs

Last edited by chrishirst; 10-17-2009 at 07:31 AM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Demos in PHP that refresh every hour
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.13151 seconds with 13 queries