View Single Post
Old 05-03-2009, 02:03 PM   #11 (permalink)
iflashlord
The Wanderer
 
iflashlord's Avatar
 
Join Date: Apr 2009
Location: Web
Posts: 5
Thanks: 18
iflashlord is on a distinguished road
Box sample back up database

PHP Code:
//$conn = your connection handle
//$dbase = your database name
// back up save in file on server
// your backup folder must safe by .htaccess (for security)
// 100% tested ok
$Backup ="";
$Tbl mysql_list_tables($dbase ,$conn);
    while(
$R_t mysql_fetch_row($Tbl)){ 
    
        
$Create_tbl mysql_query("SHOW CREATE TABLE `$R_t[0]`");
        while(
$R_c_t mysql_fetch_array($Create_tbl)){
            
$Backup .= " ".$R_c_t['Create Table'];
        }
        
        
$Backup .= ";\r\n";

        
$Q_t mysql_query("SELECT * FROM `$R_t[0]`");

        while(
$R_c_f mysql_fetch_row($Q_t)) {
            
$Backup .= "INSERT INTO `$R_t[0]` VALUES('$R_c_f[0]' ";

            for(
$i=1;$i<sizeof($R_c_f);$i++){
                
$Backup .= ", '$R_c_f[$i]' ";
            }

        
$Backup .= ");\r\n";

        }

        
$Backup .= "\r\n";
    }
$file_name date('myd').time();
$H fopen("./backup/$file_name.sql","w+");

fwrite($H,$Backup);

fclose($H); 
__________________
Create your flash banner online - site powered by php
Send a message via Yahoo to iflashlord Send a message via Skype™ to iflashlord
iflashlord is offline  
Reply With Quote