Jump to content

[SOLVED] help with crons!


uwannadonkey

Recommended Posts

im using a free host, and i need a cron for my website

 

lets say i wanna add 5 energy, every 10 minutes, right

 

how would i do it?

 

in my php, i would have

<?php

db_connect

 

then like mysql_query(update `users` SET energy= energy + (5);

?>

 

would that work? and what should i write in my crontab?

Link to comment
Share on other sites

No curl should be fine.  You can connect to the database directly from the php script called from cron.  Much like the example in your original post.

 

I can't give you a detailed example as I'm not too sure about your database setup.  But it really is as simple as your example there.  Just connect to the database and do the update.

Link to comment
Share on other sites

still not solved.!

 

all i have for crons is this:

<?php
$dbh=mysql_connect ("localhost", "donkey9_Admin", "xxx) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("donkey9_Game");

$sql2="UPDATE `users` SET energy=energy+10 WHERE energy < '$max_energy'";

if(mysql_query($sql2))
{
echo $sql2;
}

?>

as my cron.php and my command line is wget http://donkeygame.1gig.biz/cron.php

 

thats all i got, i know im doing something wrong, cuz if i  go to my cron.php page, i dont gain any energy, so i doubt if cron runs it, ill get any?

 

in ANY case, my crons arent working, i mean, im not getting any emails, and its been like 10 minutes

Link to comment
Share on other sites

Your missing the closing quote. Look...

 

<?php
$dbh=mysql_connect ("localhost", "donkey9_Admin", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("donkey9_Game");

$sql2="UPDATE `users` SET energy=energy+10 WHERE energy < '$max_energy'";

if(mysql_query($sql2))
{
echo $sql2;
}

?>

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.