Page 1 of 1
Cronjob help
Posted: Tue Jul 06, 2004 8:58 am
by Chedburn
Hey all, I need some help. I am creating a game, I have almost everything sorted appart from the cronjobs. Ive already done the timing and everything its just the php code.
Could someone please tell me the code for this?
I want to allocate 2 'awake' to all the players.
Table: users
You cant get more than 100 awake. (I could sort that bit out).
I already have the 'include connect.php' at the top so theres no point bothering with the database connect info.
Posted: Tue Jul 06, 2004 9:10 am
by JayBird
I don't think anyone will have a clue what you are talking about.
need more information
Mark
Posted: Tue Jul 06, 2004 9:18 am
by Chedburn
:/
What like? Ive shown that, it is a cronjob, that the table name is users, and that I need the code to allocate 2 awake to every player in the game.
Thanks
Posted: Tue Jul 06, 2004 9:30 am
by pickle
Are you trying to run PHP as a command line script? If so, you will need something like #!/path/to/php at the top of your script to tell the shell which interpreter to use.
feyd | fixed shebang.
Posted: Tue Jul 06, 2004 9:49 am
by redmonkey
Cron is not a programming language, it is merely a scheduler which can be setup to run scripts/apps/system commands at any interval or time of day you want (similar to Windoze Task Scheduler).
You would write your script in whatever language you like and then configure cron to access and run the script whenever you like.
The information you have given so far is nowhere near enough to enable anyone to write a php script to do what you want.
It sounds like you want someone to write the script for you? in that case your post would have been better suited in the 'Volunteer Work' or 'Job Hunt' section.
Posted: Tue Jul 06, 2004 9:52 am
by feyd
I'd agree with redmonkey, that you sound like you want it done for you.. If so, PM a mod, we'll move it.
Posted: Tue Jul 06, 2004 1:44 pm
by Chedburn
I only wanted help with writing the php code that allocates awake to every player.
Ive already set the cron job to run every 2 minutes and ive set the path too...
All i wanted was the php code. e.g.
$playersawake = $playersawake + 2
Posted: Wed Jul 07, 2004 4:50 pm
by Chedburn
This might make it clearer. This is what I want the script to do.
Select players from database;
if ($awake =< 98 )
{
$awake = $awake + 2;
}
I can make the script for one player, Im just having trouble selecting all the players from the database and using that script on all of them without visiting that page. Is that possible, or do I have to create a new table or something?
Posted: Wed Jul 07, 2004 7:19 pm
by feyd
Code: Select all
UPDATE tablename SET awake = awake + 2 WHERE awake < 98
Posted: Thu Jul 08, 2004 9:52 am
by Chedburn
Yeah, thanks... The full code i worked out is...
Code: Select all
<?php
include "connect.php";
$sql = "UPDATE users SET awake = awake +1 WHERE awake < 100";
$result = mysql_query($sql);
?>