[SOLVED] Cronjob help

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Chedburn
Forum Newbie
Posts: 5
Joined: Tue Jul 06, 2004 8:58 am

Cronjob help

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

I don't think anyone will have a clue what you are talking about.

need more information

Mark
Chedburn
Forum Newbie
Posts: 5
Joined: Tue Jul 06, 2004 8:58 am

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Chedburn
Forum Newbie
Posts: 5
Joined: Tue Jul 06, 2004 8:58 am

Post 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
Chedburn
Forum Newbie
Posts: 5
Joined: Tue Jul 06, 2004 8:58 am

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

UPDATE tablename SET awake = awake + 2 WHERE awake < 98
Chedburn
Forum Newbie
Posts: 5
Joined: Tue Jul 06, 2004 8:58 am

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

?>
Post Reply