Hello,
Have no problem with without a backup GZip
Problem creating GZip
The problem here:
[php]
//------ backup file name --------------//
if($_POST[‘gzip’]==‘1’){
$handle = fopen($datetime . ‘.sql.gz’, ‘a’);
}elseif($_POST[‘gzip’]==‘0’){
$handle = fopen($datetime . ‘.sql’, ‘a’);
}
//------ backup file name --------------//
[/php]
AND
[php]
//------ backup file name --------------//
if($_POST[‘gzip’]==‘1’){
$gzdata = gzencode($return, 9);
fwrite($handle, $gzdata);
}elseif($_POST[‘gzip’]==‘0’){
fwrite($handle, $return);
}
unset($return);
//------ backup file name --------------//
[/php]
What is wrong here?
Can you help?
All codes
[php]
<?php
include('./includes/config.php');
// BASE TABLE SAVE
//get all of the tables
$datetime = date('d-m-Y-H-i');
$tables = '*';
$return=null;
if($tables == '*'){
$tables = array();
$result = $mysqlibag->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while($row = $result->fetch_row()){
$tables[] = $row[0];
}
}else{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
foreach ($tables as $table) {
$result = $mysqlibag->query('SELECT * FROM ' . $table);
$num_fields = $result->field_count;
$return .= 'DROP TABLE IF EXISTS ' . $table . ';';
$row2 = $mysqlibag->query('SHOW CREATE TABLE ' . $table)->fetch_row();
$return .= "\n" . $row2[1] . ";\n";
//------ backup file name --------------//
if($_POST['gzip']=='1'){
$handle = fopen($datetime . '.sql.gz', 'a');
}elseif($_POST['gzip']=='0'){
$handle = fopen($datetime . '.sql', 'a');
}
//------ backup file name --------------//
for ($i = 0; $i < $num_fields; $i++) {
@set_time_limit(0);
while ($row = $result->fetch_row()) {
$return .= 'INSERT INTO `' . trim($table) . '` VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = preg_replace("/\r\n/", "\\r\\n", $row[$j]);
if (isset($row[$j])) {
$return .= "'" . $row[$j] . "'";
} else {
$return .= "''";
}
if ($j < ($num_fields - 1)) {
$return .= ',';
}
}
$return .= ");\n";
//------ backup file name --------------//
if($_POST['gzip']=='1'){
$gzdata = gzencode($return, 9);
fwrite($handle, $gzdata);
}elseif($_POST['gzip']=='0'){
fwrite($handle, $return);
}
unset($return);
//------ backup file name --------------//
}
}
fclose($handle);
}//foreach ($tables as $table) {
$mysqlibag->close();
if($handle !=""){
echo '
Backup Completed Successfully.';
}else{
echo '
Backup Error Occurred.';
}
return $handle;
?>
[/php]
Thanks in advance