I'm working on a PHP script that reads the unix timestamps stored in a MySQL database and sends an email to the address stored corresponding to that unix timestamp, in the same table. I'm utilizing CRON for such a purpose, but I've run into some troubles. The CRON is running "sender.php" every second, since I've no idea about the stored timestamp values. My analogy is, that since emails can only be sent out for time that has'nt yet passed, if I were to compare the current unix timestamp with the one in the table, the former should always be smaller than the latter. And this is what "sender.php" does. It compares the current unix timestamp with the one in the table, and if when they both become equal, the "mail()" function sends out the email.
Sender.php:
<?php
require("db.inc");
$current_time=date("U");
$sql=mysql_query("SELECT unix_date, user_email FROM events WHERE confirmed='YES' AND status='NO' ORDER BY unix_date ASC LIMIT 0, 1");
$result=mysql_fetch_row($sql);
if ($current_time==$result[0])
mail("$result[1]", "Subject", "email Content");
?>
I'm pretty sure that CRON is working properly, since I decided to run this script keeping the exit value of the if loop always true, and the email was sent. Could it be that the value of "$current_time" is'nt increasing, and never reaches the value of the timestamp, so the if condition never becomes true.