Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.