Jump to content

[SOLVED] Changing a database value at a certain time


kryppienation

Recommended Posts

I am trying to set a certain field "daily" to reset to the value of 200 in an entire table throughout all records. I am not sure how to work with time. I would like to also watch the time remaining until the reset happens... Now this time does not have to live, just a post of the time remaining that updates when i refresh is quite fine. I am not sure if i need to make another database table to hold the information or not, i am sure that i most likely do... which is completely fine. I am wondering if someone knows how i can do this?

 

Thanks!

;D

I only need to do this one time in a 24 hours period. Like once a midnight... i don't know if that makes it easier or not... but perhaps a bit less confusing. Basically i need to know how to run an update statement every 24 hours.

alright, i wrote the script and it works when i call it in my browser. I tried to do a scheduled task and i used the file as my file to run... when the time came, the file opened in mozilla... but it opened and nothing happened. The problem is when i called the file for it to work the first time, i used the url of the site.

 

 

localhost/mystuff/runthisfile.php

 

 

when it opened using the scheduled task it opened with the following:

 

file:///C:/root/mystuff/runthisfile.php

 

 

Does anyone know how i can get this file to actually run the script? I put the code in there just incase it might be userful it's very simple though.

 


<?php



include_once('../includes/db.php');

$setdaily = 'update users set daily = "200"';



DB::connect($DB_database);
DB::query($setdaily, "Set all user's to 200 daily");
DB::close();


?>

 

 

 

Well, when you run the file using scheduled task like that, you are simply opening the file.... but it is not running it through the php parser. You can make it do that with a little messing around with the PHP CLI which is a command line executable that will allow you to run php scripts that way.

 

You would basically then set the scheduled task to be

 

c:\root\php.exe fileToRun.php

 

Or you can even possibly set the scheduled task to run the file on the server

 

http://www.yoursite.com/filetorun.php

 

or http://localhost/fileToRun.php

 

Linux crontab is really much easier.

 

Nate

Ok I have done that, it still didn't change the values in my database. here is what i got.

 

 

this is all of the stuff in "RUN:"

 

C:\xampp\php\php.exe C:\xampp\htdocs\kryppienation\admin\changemotivation.php

 

 

it opens the php.exe CLI but it's not reading the file... i also tried:

 

C:\xampp\php\php.exe changemotivation.php

when i did this i made sure that the changemotivation.php and the included db.php where in the c:\xampp\php folder.

 

didn't work either

 

Thanks.

 

[attachment deleted by admin]

Check this out. wget for windows.

 

http://users.ugent.be/~bpuype/wget/

 

I was able to run a php file on my webserver using it.

 

In the scheduled task place this in it.

 

C:\wget.exe -q -O nul http://yoursite.com/path/to/file

 

The -q makes it run quiet, the -O writes the output to FILE and nul is the file it goes to ..... I think that is the way the switches work.

 

But it does work without issue.

 

Nate

 

 

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.