PHP Classes

File: demo_english.php

Recommend this page to a friend!
  Classes of pascal CASENOVE   PHPMySQLbackup   demo_english.php   Download  
File: demo_english.php
Role: Example script
Content type: text/plain
Description: example file
Class: PHPMySQLbackup
Backup a mysql database without mysqldump
Author: By
Last change: new example
Date: 20 years ago
Size: 3,728 bytes


Class file image Download
// example of a back up for a base mysql
    // to put in a folder of your site with the file phpmysqldump.pclass
    // *************warning*********
    // this folder must be reachable in writing by your web server
    // put your parameters mysql
$base="database to backup";
$login="your mysql login";
$password="you mysql password";
// ou utiliser le formulaire

// in this order a link mysql, the host address, the username, the password and the name of the base to back up
    // if the link mysql is absnt we use the host, name et pass
    // if the link is present it is the priority link, the other parameters must be ""
$sav = new phpmysqldump( $host, $login, $password, $base, "en", $link);
$base=="database to backup"){$sav->errr="input informations";}

//$sav->format_out="no_comment"; // if we donít want the comments in the dump uncomment this line
$sav->nettoyage(); // optional Ė erase the old back up files
$sav->fly=1; // not use drive send the dump directly to the browser
    //$sav->compress_ok=1; // flag to activate compression
$sav->backup(); // launch the back up
    // $sav->backup("test.sql"); // launch the back up with a filename chosen by the user
    // $sav->compress(); // optional - compress to the gz format without using the shell
                                    // it's better to use the compress_ok flag
    // a little bit of HTML to display the example
if(!$sav->errr && $sav->fly){exit();}
<title>TEST PHPMYSQLDUMP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<div align="center"><font size="+2"><strong>MySQL database backup</strong></font><br>
<form name="form1" method="post" action="">
  <table width="50%" border="1" align="center">
      <td>-<? echo $sav->host; ?>-</td>
      <td>-<? echo $sav->base; ?>-</td>
      <td>File to download</td>
      <td>-<a href="<? echo $sav->filename; ?>"><? echo $sav->filename; ?></a>-</td>
      <td>server to save</td>
      <td><input name="host" type="text" value="<? echo $host; ?>"></td>
      <td>database name to save</td>
      <td><input type="text" name="base" value="<? echo $base; ?>"></td>
      <td>Login MySQL</td>
      <td> <input type="text" name="login" value="<? echo $login; ?>"> </tr>
      <td>Password MySQL</td>
      <td><input type="text" name="password" value="<? echo $password; ?>"></td>
      <td><input type="submit" name="bouton" value="Envoyer"></td>
      <? if(!$_REQUEST[bouton]){ ?>
You can make backup :<br>
1 PHP and MySQL are on a distant WEB server you backup the database on your local
computer <br>
2 PHP is on your local computer MySQL is distant<br>
3 PHP and MySQL are on your local computer
<? } ?>
<p align="center"><font color="#FF0000" size="+1"><strong>-<? echo $sav->errr; ?>-</strong></font></p>
<p align="center"><strong><font size="-2">Contact me </font><font size="-2"> <a href=""></a>