Skip to main content

Posts

Backup Your MySQL Database Using PHP

One of the most important tasks any developer needs to do often is back up their MySQL database. In many cases, the database is what drives most of the site. While most web hosts do a daily backup of a customer's database, relying on them to make backups and provide them at no cost is risky to say the least. That's why I've created a database backup function that I can call whenever I want -- including nightly CRONs. The PHP & MySQL Code backup_tables ( 'localhost' , 'username' , 'password' , 'blog' ) ; /* backup the db OR just a table */ function backup_tables ( $host , $user , $pass , $name , $tables = '*' ) { $link = mysql_connect ( $host , $user , $pass ) ; mysql_select_db ( $name , $link ) ; //get all of the tables if ( $tables == '*' ) { $tables = array ( ) ; $result = mysql_query ( 'SHOW TABLES' ) ; while ( $row = mysql_fetch_row ( $result ) ) { $...

Send Files via FTP Using PHP

Sending files to a server via FTP is an essential ability of any web developer or designer. Of course, we all use glossy FTP clients like WS_FTP and FireFTP, but what about FTP automation? You can use PHP to FTP files from one server to another. Let me show you how.       // set_time_limit(0); $connection = ftp_connect ( "easycms.in" ) ; $login = ftp_login ( $connection , "admin@easycms.in" , "hl0809@" ) ; if ( ! $connection ) { die ( 'Connection attempt failed!' ) ; } else { echo "connection passed" ; } if ( ! $login ) { die ( 'Login attempt failed!' ) ; } else { echo "login passed" ; } ftp_pasv ( $connection , true ) ; < p> $source = "adv_banner.jpg" ; $dest = "recipe_image/adv_banner.jpg...

CRON JOB in PHP dynamically

Prerequisites: Little knowledge of MVC framework and obviously PHP. Also safe mode should be off on server and PHP function shell_exec should be enabled. I will describe how to create CRON job through PHP code within the MVC framework as simple as possible so that beginners and most programmers can easily understand. I want to describe in easy and short words as most programmers don’t feel very easy when they see a big length of an article and difficult technical wordings. I would like to name mine controller as cronController.php , model as cronModel.php and view as cronView.php Flow of creating cron job will go like this cronController.php=>cronView.php=>cronController.php=>cronModel.php Parameters from cronView.php will go to cronController.php and from cronController.php parameters will go to cronModel.php to make database operations. Here one thing should be noticed that its not necessary that you have to make model, but ...