Jump to content

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

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.