Good day everyone.
Recently I wrote a database backup script for my server. It did not work for some time due to server settings, but now it worked, but another problem appeared. Help solve it.
The problem is that backup is created with broken coding. All Russian characters are unreadable. Tell me what to add to the code to fix this problem?
Here is the code:
$dblocation = "localhost"; $dbuser = "admin"; $dbpasswd = "12345"; $dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd); $user_mysql = 'admin'; $pass_mysql = '12345'; $tmp_path = $_SERVER['DOCUMENT_ROOT'].'/uploads/damp/'; function get_database_tables() { $ret = array(); $r = mysql_query('SHOW DATABASES'); if (mysql_num_rows($r)>0) { while($row = mysql_fetch_array($r, MYSQL_NUM)) { $ret[] = $row[0]; } } return $ret; } $h=array(); $h=get_database_tables(); $vsego=count($h); $exс=array('information_schema', 'mysql', 'performance_schema', 'phpmyadmin'); for ($x=0; $x < $vsego; $x++){ $bd=$h[$x]; #И сделаем их дамп if(!in_array($bd, $exс)){ exec('mysqldump -u '.$user_mysql.' -p'.$pass_mysql.' '.$bd.' > ' . $tmp_path . $bd . '.sql'); } } echo "<pre>"; print_r($h); echo "</pre>";