TCH-JimE Posted April 21, 2005 Posted April 21, 2005 Hello, I need a cronjob.php script that will connect to mysql database and empty phpbb_sessions (not drop it, just empty it!) Anyone know what i would need in the cronjob.php bit? And then the line to enter into cronjob on cpanel? Thanks *waves to all his old friends* Jimuni Quote
TCH-JimE Posted April 21, 2005 Author Posted April 21, 2005 Would this be it? ><?php /* Start of PHP3 Script */ /* Data of SQL-server */ $server= "www.xxxx.com"; /* Address of my server */ $user= "xxxxxx"; /* Database username */ $password= "yyyyyyy"; /* Database Password */ $database= "dbxxxxxx"; /* name of database */ $table= "phpBB_sessions"; /* Name of table */ /* Accessing SQL-Server and emptying table */ MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>"); MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); $result=MYSQL_QUERY( "Empty TABLE $table"); echo "<H1>Table was deleted successfully</H1>"; /* Close SQL-Connection */ MYSQL_CLOSE(); ?> Jimuni Quote
TCH-JimE Posted April 21, 2005 Author Posted April 21, 2005 Hey, fixed it already! Here it is for anyone else: ><?php /* Start of PHP3 Script */ /* Data of SQL-server */ /* $server= ""; */ /* Not needed in this script*/ $dbhost = 'localhost'; /* I need this instead!*/ $user= "xxx"; /* Database username */ $password= "xxx"; /* Database Password */ $database= "xxx"; /* name of database */ $table= "phpBB_sessions"; /* Name of table */ /* Accessing SQL-Server and emptying table */ MYSQL_CONNECT($dbhost, $user, $password) or die ( "<H3>Server unreachable</H3>"); MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); $result=MYSQL_QUERY( "Empty TABLE $table"); echo "<H1>Table was Emptied successfully</H1>"; /* Close SQL-Connection */ MYSQL_CLOSE(); ?> Now off to work out the crontab line! Bugman Quote
TCH-Don Posted April 21, 2005 Posted April 21, 2005 Hi Jim, how are you? welcome to the self help forum Quote
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.