Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // THIS CODE SNIPPET IS FOR DEMO PURPOSE ONLY
- // Name of the file
- $filename = 'demo_restore.sql';
- // MySQL host
- $mysql_host = 'localhost';
- // MySQL username
- $mysql_username = 'eativeit_tanvir';
- // MySQL password
- $mysql_password = 'Entersandman1';
- // Database name
- $mysql_database = 'eativeit_doctorappointmentwp';
- // Connect to MySQL server
- //$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
- $link = mysqli_connect($mysql_host, $mysql_username, $mysql_password, $mysql_database);
- // Select database
- //mysql_selectdb($mysql_database , $link) or die('Error selecting MySQL database: ' . mysql_error());
- // Temporary variable, used to store current query
- $templine = '';
- // Read in entire file
- $lines = file($filename);
- // Loop through each line
- foreach ($lines as $line)
- {
- // Skip it if it's a comment
- if (substr($line, 0, 2) == '--' || $line == '')
- continue;
- // Add this line to the current segment
- $templine .= $line;
- // If it has a semicolon at the end, it's the end of the query
- if (substr(trim($line), -1, 1) == ';')
- {
- // Perform the query
- mysqli_query($link, $templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
- // Reset temp variable to empty
- $templine = '';
- }
- }
- mysqli_close($link);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement