');
print_r('Database Host :
');
print_r('Database User :
');
print_r('Database Pass :
');
print_r('Database Name :
');
print_r("
Backing up your DB tables before executing following operation is highly recommended. ");
print_r("
Will set each existing table charset and each field charset to UTF-8. OK to proceed ? ");
print_r(' ');
print_r('');
}
else{
$dbhost = $_POST['dbhost'];
$dbuser = $_POST['dbuser'];
$dbpass = $_POST['dbpass'];
$dbname = $_POST['dbname'];
print_r($dbuser);
$db = mysql_connect($dbhost,$dbuser,$dbpass);
$tables = mysql_list_tables($dbname,$db);
$error=0;
while($row = mysql_fetch_row($tables)){
$query = 'ALTER TABLE `' . $row[0] . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci';
print_r($query . "
");
$execnum++;
if(mysql_query($query,$db))
print_r("TRUE
");
else{
print_r("FALSE
" . mysql_error() . "
");
$error++;
}
$query = 'SHOW COLUMNS FROM ' . $row[0];
$result = mysql_query($query,$db);
while($row2 = mysql_fetch_assoc($result)){
$name = $row2['Field'];
$type = $row2['Type'];
$query = 'ALTER TABLE `' . $row[0] . '` CHANGE `' . $name . '` `' . $name . '` ' . $type . ' CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL';
print_r("
" . $query . "
");
$execnum++;
if(mysql_query($query,$db))
print_r("TRUE
");
else{
print_r("FALSE
" . mysql_error() . "
");
$error++;
}
}
}
print_r("
Finished! execution: ". $execnum . " error : " . $error);
}
?>