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

Link to comment
Share on other sites

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();


?>

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

 

 

Link to comment
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.