Jump to content

Cron Jobs with PHP


almightyegg

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/
Share on other sites

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 :(

Link to comment
https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267144
Share on other sites

<?

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'");
}

?>

Link to comment
https://forums.phpfreaks.com/topic/54032-cron-jobs-with-php/#findComment-267146
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.