supanoob Posted October 10, 2007 Share Posted October 10, 2007 Is is possible to use Rand in crons? the current script i have is this: <?php $dbh=mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("user"); $query="select fish_x, fish_y from game_stats"; $result=mysql_query($query); if (!$result) { die(mysql_error()); } $num_rows=mysql_num_rows($result); $row=mysql_fetch_array($result); $fish_x=($row['fish_x']); $fish_y=($row['fish_y']); $rand_x=rand(1,5); $rand_y=rand(1,5); $rand_x=$rand_x; $rand_y=$rand_y; $sql2="UPDATE game_stats SET fish_x=$rand_x, fish_y=$rand_y"; if(mysql_query($sql2)) { echo $sql2; } ?> yeah it doesnt seem to update them >< Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/ Share on other sites More sharing options...
trq Posted October 10, 2007 Share Posted October 10, 2007 Cron just calls scipts / programs at specific intervals. What those scripts / programs do has nothing at all to do with cron. The problem is more likely to do with your queries. You need to debug the script prior to having it executed by cron. Are you getting any errors? Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366298 Share on other sites More sharing options...
MmmVomit Posted October 10, 2007 Share Posted October 10, 2007 What is the point of these two lines? <?php $rand_x=$rand_x; $rand_y=$rand_y; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366300 Share on other sites More sharing options...
supanoob Posted October 10, 2007 Author Share Posted October 10, 2007 nope im not even getting the email saying it went through or it didnt. Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366304 Share on other sites More sharing options...
MmmVomit Posted October 10, 2007 Share Posted October 10, 2007 What email? Your script doesn't send an email. Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366317 Share on other sites More sharing options...
supanoob Posted October 10, 2007 Author Share Posted October 10, 2007 the ones the cronjob sends for you. Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366319 Share on other sites More sharing options...
trq Posted October 10, 2007 Share Posted October 10, 2007 Like I said, you need to debug the scrit prior to having it executed via cron. Your problem however might actually be that cron isn't executing the script. Can wee see your crontab? the ones the cronjob sends for you. Cron does not send emails. Like I said, Cron just calls scipts / programs at specific intervals. Thats all it does. If your meant to recieve an email when a cronjob is run, this is done by some other meens/configuration. Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366370 Share on other sites More sharing options...
supanoob Posted October 10, 2007 Author Share Posted October 10, 2007 just fixed it thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/72651-solved-cron-jobs/#findComment-366380 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.