There is a file handler that creates a database dump on the hosting, but I can not download it.

<?php if( isset( $_POST['dump'] ) ) { $server = "";//СЕРВЕР MYSQL $user_db = "";//ЮЗЕР MYSQL $pass_db = "";//ПАРОЛЬ MYSQL $base_db = "";//ИМЯ_БАЗЫ MYSQL $mysqli = new mysqli($server, $user_db, $pass_db, $base_db); $results = mysqli_query($mysqli,'SELECT user.id, user.login, user.mail, user_inf.f_name, user_inf.l_name, user_inf.b_date FROM user JOIN user_inf ON user.id = user_inf.id ORDER BY user.id ASC'); while ($row = $results->fetch_assoc()) { $Array_for_dump['id'][] = $row['id']; $Array_for_dump['login'][] = $row['login']; $Array_for_dump['mail'][] = $row['mail']; $Array_for_dump['f_name'][] = $row['f_name']; $Array_for_dump['l_name'][] = $row['l_name']; $Array_for_dump['b_date'][] = $row['b_date']; } require_once('PHPExcel.php'); $phpexcel = new PHPExcel(); $titles = array ( array ( 'name' => 'ID', 'cell' => 'A' ), array ( 'name' => 'login', 'cell' => 'B' ), array ( 'name' => 'mail', 'cell' => 'C' ), array ( 'name' => 'f_name', 'cell' => 'D' ), array ( 'name' => 'l_name', 'cell' => 'E' ), array ( 'name' => 'b_date', 'cell' => 'F' ) ); for( $i = 0; $i < count($titles); $i++){ $string = $titles [$i]['name']; $cellLetter = $titles[$i]['cell'] . 1; $phpexcel->getActiveSheet()->setCellValueExplicit($cellLetter, $string, PHPExcel_Cell_DataType::TYPE_STRING); } $i = 2; for ($j = 0; $j < count($Array_for_dump['id']); $j++){ $phpexcel->getActiveSheet()->setCellValue("A$i", $Array_for_dump['id'][$j]); $phpexcel->getActiveSheet()->setCellValueExplicit("B$i", $Array_for_dump['login'][$j], PHPExcel_Cell_DataType::TYPE_STRING); $phpexcel->getActiveSheet()->setCellValueExplicit("C$i", $Array_for_dump['mail'][$j], PHPExcel_Cell_DataType::TYPE_STRING); $phpexcel->getActiveSheet()->setCellValueExplicit("D$i", $Array_for_dump['f_name'][$j], PHPExcel_Cell_DataType::TYPE_STRING); $phpexcel->getActiveSheet()->setCellValueExplicit("E$i", $Array_for_dump['l_name'][$j], PHPExcel_Cell_DataType::TYPE_STRING); $phpexcel->getActiveSheet()->setCellValueExplicit("F$i", $Array_for_dump['b_date'][$j], PHPExcel_Cell_DataType::TYPE_STRING); $i++; } $page = $phpexcel->setActiveSheetIndex(); $page->setTitle("Dump_DataBase"); $objWriter = PHPExcel_IOFactory::createWriter($phpexcel, 'Excel2007'); $filename = "Dump_DataBase.xlsx"; if ( file_exists($filename)) { unlink($filename); } $objWriter->save($filename); if (file_exists($filename)) { // сбрасываем буфер вывода PHP, чтобы избежать переполнения памяти выделенной под скрипт // если этого не сделать файл будет читаться в память полностью! if (ob_get_level()) { ob_end_clean(); } // заставляем браузер показать окно сохранения файла header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($filename)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($filename)); $message = 'Successfully completed!'; $color = 'green'; $out = array( 'message' => $message, 'color' => $color ); header('Content-Type: text/json; charset=utf-8'); echo json_encode($out); die; } ?> 
  • What do you mean you can not download? - andreymal
  • Wang that the runtime of the script ends) is not it easier to use mysqldump ? or no server access over SSH? - Andrey Ivasko
  • @andreymal well, the file on the hosting is created and that's it, downloading does not happen - Ayurpwnz
  • @Ayurpwnz and what happens instead of downloading? - andreymal
  • @andreymal say nothing. File is created and everything, signs of life does not give - Ayurpwnz

0