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? Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/ 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? Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298736 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 Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298740 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 ? Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298748 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 Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298751 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 >< Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298760 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 ? Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298762 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. Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298765 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 Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298773 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. Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298777 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. Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298779 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. Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298783 Share on other sites More sharing options...
keeB Posted July 15, 2007 Share Posted July 15, 2007 What does -q do? Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298799 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. Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298800 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; } ?> Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298833 Share on other sites More sharing options...
supanoob Posted July 15, 2007 Author Share Posted July 15, 2007 Solved thanks Link to comment https://forums.phpfreaks.com/topic/60064-solved-crons-errors/#findComment-298879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.