$php_mysql$ Posted August 11, 2011 Share Posted August 11, 2011 could someone check what is wrong in this code that no db entry nor image is being deleted $time_count = 2*24*60*60; $match_time = time() - $time_count; $sql="SELECT id FROM tbl WHERE adtime < '".$match_time."'"; $result=mysql_query($sql); if(!$result){ echo 'SELECT failed: '.mysql_error(); }else{ while($row=mysql_fetch_array($result)){ $id = $row['id']; if(!unlink($row['image'])){ echo "unlink ".$row['image']." failed"; }else{ } $sql="DELETE FROM tbl WHERE id = '".$id."'"; $result= mysql_query($sql); if(!$result){ echo 'DELETE from tbl with id '.$id.' failed: '.mysql_error(); } executeSql($sql); } } Quote Link to comment https://forums.phpfreaks.com/topic/244537-cron-job-not-taking-effect/ Share on other sites More sharing options...
Maq Posted August 11, 2011 Share Posted August 11, 2011 Can you run it in a regular script? If it doesn't work specifically when you run it in cron then it's probably permissions. I don't see any DB connection credentials either. Quote Link to comment https://forums.phpfreaks.com/topic/244537-cron-job-not-taking-effect/#findComment-1256066 Share on other sites More sharing options...
darkfreaks Posted August 11, 2011 Share Posted August 11, 2011 Make sure your chmod permissions on crontab.php script is set to 755 or 777 http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/ This really explains how to create a PHP class that handles cron jobs using PHP. Quote Link to comment https://forums.phpfreaks.com/topic/244537-cron-job-not-taking-effect/#findComment-1256070 Share on other sites More sharing options...
$php_mysql$ Posted August 11, 2011 Author Share Posted August 11, 2011 yes i can run it on regular script without errors but its just not doing its job, how do i set permission if required? Quote Link to comment https://forums.phpfreaks.com/topic/244537-cron-job-not-taking-effect/#findComment-1256076 Share on other sites More sharing options...
$php_mysql$ Posted August 11, 2011 Author Share Posted August 11, 2011 oh thats soo much , let me try it Quote Link to comment https://forums.phpfreaks.com/topic/244537-cron-job-not-taking-effect/#findComment-1256077 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.