almightyegg Posted June 2, 2007 Share Posted June 2, 2007 I use CPanel to control my site and I think cron jobs can do what I want on my site. I have a few questions: 1) How do you write a Cron Job to open a script on your website. 2) Can the script be in any language (PHP, Perl etc..) 3) If you can use PHP with it, would this script work? $selectall = mysql_query("SELECT * FROM users"); $selectall2 = mysql_fetch_array($selectall); while($selectall2){ $column1 = $selectall2['column1']+20; $column2 = $selectall2['column2']+80; $query = mysql_query("UPDATE users SET column1='$column1', column2='$column2'"); } Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/ Share on other sites More sharing options...
saf Posted June 2, 2007 Share Posted June 2, 2007 Is this a one time thing or is it recursive? Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267130 Share on other sites More sharing options...
almightyegg Posted June 2, 2007 Author Share Posted June 2, 2007 recursive. It will happen once a day Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267131 Share on other sites More sharing options...
almightyegg Posted June 2, 2007 Author Share Posted June 2, 2007 Right I've worked it all out now (I think) except my script that I'm running never stops loading (the MySQL table is successfully updated though) <? include 'db.php'; $selectall = mysql_query("SELECT * FROM users"); $selectall2 = mysql_fetch_array($selectall); while($selectall2){ $mot = $selectall2['mot']+120; $daysold = $selectall2['daysold']+1; $query = mysql_query("UPDATE users SET mot='$mot',daysold='$daysold'"); } ?> I knew I had to use a while but I didn't know how to stop it Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267144 Share on other sites More sharing options...
chigley Posted June 2, 2007 Share Posted June 2, 2007 <? include 'db.php'; $selectall = mysql_query("SELECT * FROM users"); while($selectall2 = mysql_fetch_assoc($selectall)) { $mot = $selectall2['mot']+120; $daysold = $selectall2['daysold']+1; $query = mysql_query("UPDATE users SET mot='$mot',daysold='$daysold'"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267146 Share on other sites More sharing options...
almightyegg Posted June 2, 2007 Author Share Posted June 2, 2007 Thanks it worked Now I just need to wait and see whether I set up my cron job right Quote Link to comment https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267159 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.