Can anyone help me on this? I have a friend adder site for blogtv members: webcamadds.com Someone set up a cron job for me awhile ago that is supposed to reset the points for all the site's users at midnight each night. But it's not resetting the points. This is what the code looks like in the reset.php file: <?php include('../sqlc.php'); // Reset site at midnight mysql_query("TRUNCATE added"); mysql_query("UPDATE members SET points='0', added='0', referrals='0', requests='0'"); mysql_query("UPDATE members SET daysleft=daysleft-1 WHERE daysleft > 0"); mysql_query("OPTIMIZE TABLE members"); mysql_query("OPTIMIZE TABLE news_comments"); ?> Code (markup): lynx -dump http://webcamadds.com/assets/c/reset.php /dev/null 2>&1 Code (markup):
you need to put in some logging or error handling. Perhaps this would be useful. If a query fails then it gets emailed to you before it shuts down. then when its all done it emails you too... if it gets that far. include('../sqlc.php'); // Reset site at midnight function runSql($sql) { mysql_query($sql) or die(mail('me@mysite.com', 'Cron Failure: '.date('d-m-Y'), $sql)); } runSql("TRUNCATE `added`"); runSql("UPDATE `members` SET `points`='0', added='0', `referrals`='0', `requests`='0'"); runSql("UPDATE `members` SET `daysleft`=`daysleft`-1 WHERE `daysleft` > 0"); runSql("OPTIMIZE TABLE `members`"); runSql("OPTIMIZE TABLE `news_comments`"); mail('me@mysite.com', 'Success: '.date('d-m-Y'), 'The cron job completed'); PHP:
Well, i used the code you posted and it sent me a single query failure email notification so it is still not resetting the points. anyone have any suggestions for fixing this? thank you.
which query did it fail on? this one? runSql("UPDATE `members` SET `points`='0', added='0', `referrals`='0', `requests`='0'"); Code (markup): what happens when you run it from phpMyAdmin/SqlYog etc? what error do you get?
Well, this is all that was in the error email: Cron <blogtv@srv1> lynx -dump http://webcamadds.com/assets/c/reset.php /dev/null 2>&1 I'm sorry, I wouldn't know how to run it from phpMyAdmin. Do I just paste the code into the SQL text box field and save it?
Okay, I was able to run it from phpMyAdmin/sqlyog and this is what I got: There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem ERROR: Unknown Punctuation String @ 1 STR: <? SQL: <?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php');<?php include('../sqlc.php'); SQL query: <?php include('../sqlc.php'); MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php include('../sqlc.php')' at line 1