Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. // THIS CODE SNIPPET IS FOR DEMO PURPOSE ONLY
  2. // Name of the file
  3. $filename = 'demo_restore.sql';
  4. // MySQL host
  5. $mysql_host = 'localhost';
  6. // MySQL username
  7. $mysql_username = 'eativeit_tanvir';
  8. // MySQL password
  9. $mysql_password = 'Entersandman1';
  10. // Database name
  11. $mysql_database = 'eativeit_doctorappointmentwp';
  12.  
  13. // Connect to MySQL server
  14. //$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
  15. $link = mysqli_connect($mysql_host, $mysql_username, $mysql_password, $mysql_database);
  16.  
  17. // Select database
  18. //mysql_selectdb($mysql_database , $link) or die('Error selecting MySQL database: ' . mysql_error());
  19.  
  20. // Temporary variable, used to store current query
  21. $templine = '';
  22. // Read in entire file
  23. $lines = file($filename);
  24. // Loop through each line
  25. foreach ($lines as $line)
  26. {
  27. // Skip it if it's a comment
  28. if (substr($line, 0, 2) == '--' || $line == '')
  29. continue;
  30.  
  31. // Add this line to the current segment
  32. $templine .= $line;
  33. // If it has a semicolon at the end, it's the end of the query
  34. if (substr(trim($line), -1, 1) == ';')
  35. {
  36. // Perform the query
  37. mysqli_query($link, $templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
  38. // Reset temp variable to empty
  39. $templine = '';
  40. }
  41. }
  42.  
  43. mysqli_close($link);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement