userdata['acclevel'] < 80) die ('Access denied!'); ?>      title; ?>

0) { echo 'Run these statements against your MySql database

'; echo "ALTER DATABASE `".DB_NAME."` DEFAULT CHARACTER SET $character_set COLLATE $convert_to;
"; $rs_tables = $db->query('SHOW TABLES') or die(mysql_error()); while ($row_tables = $db->fetch_row($rs_tables)) { $table = mysql_real_escape_string($row_tables[0]); echo "ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;
"; $rs = $db->query("SHOW FULL FIELDS FROM `$table` WHERE collation is not null AND collation <> 'utf8_general_ci'") or die(mysql_error()); while ($row=mysql_fetch_assoc($rs)) { if ($row['Collation'] == '') continue; if ( strtolower($row['Null']) == 'yes' ) $nullable = ' NULL '; else $nullable = ' NOT NULL'; if ( $row['Default'] === NULL && $nullable = ' NOT NULL ') $default = " DEFAULT ''"; else if ( $row['Default'] === NULL ) $default = ' DEFAULT NULL'; else if ($row['Default']!='') $default = " DEFAULT '".mysql_real_escape_string($row['Default'])."'"; else $default = ''; $field = mysql_real_escape_string($row['Field']); echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default;
"; } } } else { echo "Converting database, table, and row collations to utf8:

'; echo 'Done.

'; } } else { ?>

Resets DB Collations if you get collation errors after an upgrade from another HLstats(X)-based system.

You should not lose any data, but be sure to back up your database before running to be on the safe side.


Run the commands on the database
Print the commands and I'll run them myself (recommended if you have a very large database likely to hang the script)