Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

Hey, fixed it already! :thumbup1:

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...