Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>DB-Convert</title>
  5. <style>
  6. body {
  7. font-family:"Courier New", Courier, monospace;"
  8. }
  9. </style>
  10. </head>
  11. <body>
  12. <h1>Convert your Database to utf8_general_ci!</h1>
  13. <form action="db-convert.php" method="post">
  14. dbname: <input type="text" name="dbname"><br>
  15. dbuser: <input type="text" name="dbuser"><br>
  16. dbpass: <input type="text" name="dbpassword"><br>
  17. <input type="submit">
  18. </form>
  19. </body>
  20. </html>
  21. <?php
  22. if ($_POST) {
  23. $dbname = $_POST['dbname'];
  24. $dbuser = $_POST['dbuser'];
  25. $dbpassword = $_POST['dbpassword'];
  26.  
  27. $con = mysql_connect('localhost',$dbuser,$dbpassword);
  28. if(!$con) { echo "Cannot connect to the database ";die();}
  29. mysql_select_db($dbname);
  30. $result=mysql_query('show tables');
  31. while($tables = mysql_fetch_array($result)) {
  32. foreach ($tables as $key => $value) {
  33. mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
  34. }
  35. }
  36. echo "<script>alert('The collation of your database has been successfully changed!');</script>";
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement