Guest User

Untitled

a guest
Jun 24th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2.  
  3. // Database info
  4.  
  5.  
  6. include("conf_global.php");
  7.  
  8.  
  9. $dbhost = $INFO['sql_host'];
  10.  
  11. $dbuser = $INFO['sql_user'];
  12.  
  13. $dbpass = $INFO['sql_pass'];
  14.  
  15. $dbname = $INFO['sql_database'];
  16.  
  17.  
  18. //---------------
  19.  
  20.  
  21. header('Content-type: text/plain');
  22.  
  23.  
  24. $dbconn = mysql_connect($dbhost, $dbuser, $dbpass) or die( mysql_error() );
  25.  
  26. $db = mysql_select_db($dbname) or die( mysql_error() );
  27.  
  28.  
  29. $sql = "ALTER DATABASE `".$dbname."` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
  30.  
  31. $result = mysql_query($sql) or die( mysql_error() );
  32.  
  33. print "Database changed to UTF-8.\n";
  34.  
  35.  
  36. $sql = 'SHOW TABLES';
  37.  
  38. $result = mysql_query($sql) or die( mysql_error() );
  39.  
  40.  
  41. while ( $row = mysql_fetch_row($result) )
  42.  
  43. {
  44.  
  45. $table = mysql_real_escape_string($row[0]);
  46.  
  47. $sql = "ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci, CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
  48.  
  49. mysql_query($sql) or die( mysql_error() );
  50.  
  51. print "$table changed to UTF-8.\n";
  52.  
  53. }
  54.  
  55.  
  56. mysql_close($dbconn);
  57.  
  58. ?>
Add Comment
Please, Sign In to add comment