Php-mysql Course

This is a free and open source PHP script to Backup MySQL Database. The script creates the backup of the MySQL tables in SQL format and saves it into a ZIP file on server. The SBMD script can also restore the MySQL tables in your database from the SQL backup stored in ZIP archive.
You can also Download, and Delete the ZIP archives with the SQL backup.

• To Download the script, click this link: Download SBMD (12 KB).

For questions or problems related to this script, you can post on Forum.

Features

- Simple and easy to use interface to Backup and Restore MySQL tables.
- Supports both PDO and MySQLi for accessing MySQL databases in PHP.
- You can select the MySQL tables which to backup.
- The backup of the MySQL tables it is saved into a ZIP archive on server.
- You can Restore, Download, and Delete the ZIP file with backup from server.
- The script can be easily translated and used in other languages, without affecting the code.
- Easily to integrate into a CMS or other PHP project to add the backup MySQL database functionality.

Requirements

- PHP 5.4+
- Modern Browser with JavaScript enabled (Mozilla-Firefox, Google-Chrome, Opera, Internet-Explorer 9+).

Screenshoots

- Click on images:
SBMD - Connect SBMD - Tables list SBMD - Backup files list

Installation

  1. Download the archive with the script from the link above, and unzip it on your computer.
  2. Copy the "sbmd" folder on your server (with all its content).
  3. Set CHMOD 0755 (or 0777) permissions to the "backup/" folder on your server (it is used to store the ZIP files with the SQL backup).
  4. Access the "sbmd/bkmysql.php" file in your browser, with the address from server; for example: http://localhost/sbmd/bkmysql.php
  5. Add your connection data (MySQL server, Username, Password, Database name) to connect to your MySQL database. Then you can backup MySQL tables, and restore, download or delete the backup.

Other Specifications

• If you want to save the ZIP files in other directory on your server, modify the value of the $dir variable in the "bkmysql.php" file (line 5).

• If you want to use the script in other language, translate the texts from the lang_en.json file and save it in other "lang_...json" file, with the indice of the language, for example for Chinese save the texts in the "lang_ch.json". The texts in the ".json" file must be stored in valid JSON format. Then, change the value of the $lang variable in the "bkmysql.php" file (line 4) with the same indice ($lang ='ch';).

Advanced Usage

- If you want to use the backupmysql class into a CMS or other PHP project, include the backupmysql.class.php file in your project.
- The object instance of the backupmysql class requires two arguments: the indice of the language (used for the "lang_...json" file; default "en"), and the directory name where the backup files are saved (default "backup/").
Example:
include 'backupmysql.class.php';
$obj = new backupmysql('en', 'backup/');
- Then you can use these methods: - By default, the backupmysql class uses MySQLi to connect to database. If the MySQLi extension is not available, the class will try to use PDO. If you want to make the default mode to PDO, set the "pdo" value to the $conn_mod property, in the backupmysql.class.php file (line 114).

Example usage of backupmysql class

- Using backupmysql class to create backup of all the tables in mysql database.
//data for connecting to MySQL
$conn_data = ['host'=>'localhost', 'user'=>'user_name', 'pass'=>'password', 'dbname'=>'database_name'];

$lang ='en';  //indice of the "lang_...json" file with texts
$dir ='backup/';  //folder to store the ZIP archive with SQL backup

//set object of backupmysql class
include 'backupmysql.class.php';
$bk = new backupmysql($lang, $dir);

$bk->setMysql($conn_data);  //set connection
$tables = $bk->getTables();  //get array with all the tables in database

//if no error
if($bk->error === false){
  //if tables, creates the SQL backup of all the tables and saves it in ZIP archive (get succesful or error message)
  $bk_sql = (count($tables) >0) ? $bk->saveBkZip($tables) :'No tables in database';

  echo $bk_sql; 
}
else echo $bk->error; 

• This script is Free, and Open Source. You can use, modify and publish it freely.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://coursesweb.net/css/</li>
</ul>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block
.some_class {
  display: list-item;
}
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
SBMD - Simple Backup MySQL Database

Last accessed pages

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (141748)
  2. Add, Change, and Remove Attributes with jQuery (46356)
  3. Node.js Move and Copy file (28419)
  4. Rectangle, Oval, Polygon - Star (3322)
  5. PHP PDO - prepare and execute (9187)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (472)
  2. CSS cursor property - Custom Cursors (78)
  3. The Mastery of Love (69)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (62)
  5. CSS3 2D transforms (46)