<?php
mysql_select_db('database', mysql_connect('127.0.0.1', 'username', 'password')) or die (mysql_error());
function convertCharset($table)
{
$query1 = mysql_query('SHOW COLUMNS FROM `' . $table . '`');
while($row1 = mysql_fetch_assoc($query1))
{
if(!preg_match('/int/', strtolower($row1['Type'])))
mysql_query('ALTER TABLE `' . $table . '` CHANGE `' . $row1['Field'] . '` `' . $row1['Field'] . '` ' . $row1['Type'] . ' CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL') or die (mysql_error());
}
}
convertCharset('tableName');
?>