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
https://forums.phpfreaks.com/topic/60064-solved-crons-errors/
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
https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298783
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
https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298833
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.