Browsing articles tagged with " database"
Feb
22
2010

How to change the collation for all tables in a MySQL database to UTF-8?

<?php $db = mysql_connect("localhost", "username", "pass"); if(!$db) echo "Cannot connect to the database – incorrect details"; mysql_select_db(‘myuser_mydbname’); $result=mysql_query(‘show tables’); while($tables = mysql_fetch_array($result)) { foreach ($tables as $key => $value) { mysql_query("ALTER TABLE $value COLLATE utf8_slovenian_ci"); }} echo "The collation of your database has been successfully changed!"; ?>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes