Php script from cron check

Hi, i have php script which is outside web dir that deletes unconfirmed users from db when run via cron, could someone have quick look and check it is ok.

thanks


#!/usr/bin/php -q
<?php
  // cron job to delete inactive users older than 2 Days
  $db=mysql_connect('localhost','dbname','password');
  mysql_select_db('dbname',$db);
  $strSQL="DELETE FROM `PLD_USER` WHERE `EMAIL_CONFIRMED` = '0' AND `REGISTRATION_DATE` < (CURDATE() - INTERVAL 2 DAYS);"
?>



Why don’t you check it yourself? Copy the script

<?php
  // cron job to delete inactive users older than 2 Days
  $db=mysql_connect('localhost','dbname','password');
  mysql_select_db('dbname',$db);
  $strSQL="DELETE FROM `PLD_USER` WHERE `EMAIL_CONFIRMED` = '0' AND `REGISTRATION_DATE` < (CURDATE() - INTERVAL 2 DAYS);"
?>

to a page in the web directory and run it after adding a few test cases to the database that should be deleted. Then check the database. Presto! You’re done!

It doesn’t actually perform the query, so I’d be surprised if anything happens when you run that script…

Also, mysql_ is deprecated and it is recommended you switch to mysqli or PDO

Yes, you need to test this independent of the cron job, and once its working go back and implement the cron job.

Just make it into a php file, go to it in browser, and then check your DB for the changes. Fix until you see the changes you are supposed to see. Check yoru error_log file in root to see whats happening.

The folks above are right, your current implementation is incomplete. It never actually executes the sql. Google for PDO examples.