Advertisement
Guest User

Untitled

a guest
Sep 1st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>DB-Convert</title>
  5. <style>
  6. body { font-family:"Courier New", Courier, monospace;" }
  7. </style>
  8. </head>
  9. <body>
  10.  
  11. <h1>Convert your Database to utf8_general_ci!</h1>
  12.  
  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.  
  23. if ($_POST) {
  24. $dbname = $_POST['dbname'];
  25. $dbuser = $_POST['dbuser'];
  26. $dbpassword = $_POST['dbpassword'];
  27.  
  28. $con = mysql_connect('localhost',$dbuser,$dbpassword);
  29. if(!$con) { echo "Cannot connect to the database ";die();}
  30. mysql_select_db($dbname);
  31. $result=mysql_query('show tables');
  32. while($tables = mysql_fetch_array($result)) {
  33. foreach ($tables as $key => $value) {
  34. mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
  35. }}
  36. echo "<script>alert('The collation of your database has been successfully changed!');</script>";
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement