Advertisement
Guest User

Untitled

a guest
Mar 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. // Name of the file
  5. $filename = 'matchme.sql';
  6. // MySQL host
  7. $mysql_host = 'localhost';
  8. // MySQL username
  9. $mysql_username = 'condor5_root';
  10. // MySQL password
  11. $mysql_password = 'K3s7NRIP0V-@';
  12. // Database name
  13. $mysql_database = 'condor5_matchme';
  14.  
  15. // Connect to MySQL server
  16. mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
  17. // Select database
  18. mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());
  19.  
  20. mysql_query("DROP DATABASE condor5_matchme");
  21. mysql_query("CREATE DATABASE condor5_matchme");
  22.  
  23. // Connect to MySQL server
  24. mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
  25. // Select database
  26. mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());
  27.  
  28. // Temporary variable, used to store current query
  29. $templine = '';
  30. // Read in entire file
  31. $lines = file($filename);
  32. // Loop through each line
  33. foreach ($lines as $line)
  34. {
  35. // Skip it if it's a comment
  36. if (substr($line, 0, 2) == '--' || $line == '')
  37. continue;
  38.  
  39. // Add this line to the current segment
  40. $templine .= $line;
  41. // If it has a semicolon at the end, it's the end of the query
  42. if (substr(trim($line), -1, 1) == ';')
  43. {
  44. // Perform the query
  45. mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
  46. // Reset temp variable to empty
  47. $templine = '';
  48. }
  49. }
  50.  
  51. echo "Tables imported successfully";
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement