SQL Error:
' . mysql_error() . "\n"; } // Loop through all tables in this database while ( $row = mysql_fetch_row($result) ) { $table = mysql_real_escape_string($row[0]); $sql2 = "ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"; if ( !($result2 = mysql_query($sql2)) ) { print 'SQL Error:
' . mysql_error() . "
\n"; break; } print "$table changed to UTF-8 successfully.
\n"; // Now loop through all the fields within this table $sql3 = "SHOW COLUMNS FROM $table"; if ( !($result3 = mysql_query($sql3)) ) { print 'SQL Error:
' . mysql_error() . "
\n"; break; } while ( $row3 = mysql_fetch_row($result3) ) { $field_name = $row3[0]; $field_type = $row3[1]; // Change text based fields $skipped_field_types = array('char', 'text', 'enum', 'set'); foreach ( $skipped_field_types as $type ) { if ( strpos($field_type, $type) !== false ) { $sql4 = "ALTER TABLE $table CHANGE `$field_name` `$field_name` $field_type CHARACTER SET utf8 COLLATE utf8_general_ci"; if ( !($result4 = mysql_query($sql4)) ) { print 'SQL Error:
' . mysql_error() . "
\n"; break 3; } print "---- $field_name changed to UTF-8 successfully.
\n"; } } } print "
\n"; } mysql_close($connection); ?>