Web Analytics Made Easy -
StatCounter PHP Cron, Help Please - CodingForum

Announcement

Collapse
No announcement yet.

PHP Cron, Help Please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP Cron, Help Please

    Well on my site ive got a timetable for dj's and every sunday I want slots that arnt set to permanent deleted ready for the next week. Now im not sure were to start! but heck ill give it a try.

    <?php
    include("config.php");
    $admin = ('Skycaptain')
    $date = date('Ymd');
    $username = mysql_query("select * from timetable where perm = 'no'");

    //sends them a pm saying there slot was deleted (Seperetly)

    $send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` ,
    `touser` , `from` , `unread` ,
    `date` ) VALUES ('Your Slot(s)', 'Dear $username your slot(s) has expired and was deleted, <br>if you want to add it again or as a permanent slot please do so by <Br><a href=\"timetable/submit_show.php\">Clicking Here</a>', '$username',
    '$admin', 'unread', NOW())");

    //sends a pm to admin (Togethor)

    $send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` ,
    `touser` , `from` , `unread` ,
    `date` ) VALUES ('Non-Perm Slots', '$username s slots were deleted Successfully', '$admin',
    'Slot Bot', 'unread', NOW())");

    //deletes the non permanent slots

    $reset = mysql_query("DELETE FROM timetable WHERE perm='no'");
    ?>

    I Also want it to send a private message to them telling them it was deleted.

    Saved as "cron.php" saved in public html / spanel .
    And I want it to do this every sunday at midnight.

    I know were to go in cpanel to add cron but how to i do it.
    Last edited by MarvinHalliwell; Sep 28, 2006, 02:07 AM.

  • #2
    Cron jobs are (majorly) set from your control panel. There is this kinda GUI in cpanel that enables you to set cron works. All u av to do is set the date, time and other things and it works on does it for u at that time, on its own. However, u av to do at ur end is create a PHP script that will go to the database, select those u want to mail (select * from timetable where perm = 'no' , I guess) loop thru the records and mail them (probably with mail()).
    with that, u can then set ur cron from ur cpanel to run the script at your own specified time. This may not be the best of answer to ur question, but i hope it helps

    Comment

    Working...
    X