Tuesday 23 October 2012

cron it manually

<?php


$con = mysql_connect('localhost','root','');
if(!$con)
{
die("Error in database connection");
}
$sdb=mysql_select_db('mysite',$con);
if(!$sdb)
{
die("Erroe in database selection");
}
$select=mysql_query("select * from task order by id desc limit 1");
while($row=mysql_fetch_array($select)){$last_date=strtotime($row['last_run']);}



echo strtotime(date("d-m-y"))."</br>";
$today=date("d");
echo "todays date : ".date("d")."<br>";
$expiry = "23";
$date=strtotime(date('d-m-y'));
$d=date('d-m-y');
echo "last date".$last_date;

if($today==$expiry && $date!=$last_date){ echo "Code is executed";
$insert="insert into task (last_run,status)values('".$d."','1')";
$result=mysql_query($insert);



}
else{echo "this code will be executed after sometime and the last run is :".$last_date;}


?>