supanoob Posted July 15, 2007 Share Posted July 15, 2007 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? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 15, 2007 Share Posted July 15, 2007 what command line you using to setup the cronjob? Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 what command line you using to setup the cronjob? this one: php -q /crons/fatigue.php Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2007 Share Posted July 15, 2007 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 ? Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 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 Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 that aint working at all now, i aint even gettin the emails through >< Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 15, 2007 Share Posted July 15, 2007 whats the exact command line you just used ? Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 i am currently using: php -q /home/wwwporkp/crons/fatigue.php and gettin the email now that says no input file specified. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 15, 2007 Share Posted July 15, 2007 have you tried wget http://www.yoursite.com/update.php Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 have you tried wget http://www.yoursite.com/update.php it would have to be in the public folder then, but i dont want anyone to be able to set it off. Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2007 Share Posted July 15, 2007 Your path is incorrect. We can only guess at the location, its up to you to actually find it. Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 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. Quote Link to comment Share on other sites More sharing options...
keeB Posted July 15, 2007 Share Posted July 15, 2007 What does -q do? Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2007 Share Posted July 15, 2007 What does -q do? Quiet. i have the cron running now but the code doesnt seem to be executing. The email is coming up blank There is nothing in your code that sends an email. Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted July 15, 2007 Share Posted July 15, 2007 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; } ?> Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 Solved thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.