Jump to content

[SOLVED] Crons Errors


supanoob

Recommended Posts

Ok so i am sorta new to crons, meaning ive done them once or twice but lost them and am all confused all over again..

 

i have one set up like so:

 


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

$sql2="UPDATE accounts SET energy=energy+10 WHERE fatigue < '$max_energy'";
if(mysql_query($sql2))

echo "$sql2";

?>

 

and i get the follwing error in the email

 

crons/fatigue.php: line 1: ?php: No such file or directory

crons/fatigue.php: line 2: syntax error near unexpected token `"localhost",'

crons/fatigue.php: line 2: `$dbh=mysql_connect ("localhost", "wwwporkp_porky",

"<password>") or die ('I cannot connect to the database because: ' . mysql_error());'

 

Any idea why?

Link to comment
Share on other sites

php -q /crons/fatigue.php

 

That path does not look at all correct. /cron points to a directory cron within the systems root / directory.

 

Sure it shouldn't be something more like....

 

php -q /home/username/crons/fatigue.php

 

?

Link to comment
Share on other sites

php -q /crons/fatigue.php

 

That path does not look at all correct. /cron points to a directory cron within the systems root / directory.

 

Sure it shouldn't be something more like....

 

php -q /home/username/crons/fatigue.php

 

?

 

ill try that now

Link to comment
Share on other sites

i have the cron running now but the code doesnt seem to be executing. The email is coming up blank

 

<?php
$dbh=mysql_connect ("localhost", "wwwporkp_porky", "<password>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("wwwporkp_game");

$sql2="UPDATE accounts SET energy=energy+10 WHERE energy < '$max_energy'";
if(mysql_query($sql2))

echo "$sql2";

?>

 

that is what im trying to execute.

Link to comment
Share on other sites

It depends where he is running the cron, but cpanel crons automatically send an email with the output of the script each time it is executed.

 

Try this.  I've added braces to if(mysql_query($sql2)) and removed the "" around $sql2.

<?php
$dbh=mysql_connect ("localhost", "wwwporkp_porky", "<password>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("wwwporkp_game");

$sql2="UPDATE accounts 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.