 
<?php
	//MySQL connection parameters
	$dbhost = '127.0.0.1';
	$dbuser = 'vaggelis.t';
	$dbpass = 'vs0760!';
	$dbname = 'test11111';
 
	$filename = 'backup-09-12-2020.sql';
 
	//Connects to mysql server
 	$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
        mysqli_set_charset($conn, "utf8");
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
$i=0;

foreach ($lines as $line) {

// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || 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) == ';') {
   $i++;
	if ($result = mysqli_query($conn, $templine)) {
	 echo $i."<br>";
	 //echo "Returned rows are: " . mysqli_num_rows($result);
	  // Free result set
	  mysqli_free_result($result);
	}else{
		print('Error performing query \'<strong>' . $templine . '\': ' . mysqli_error() . '<br /><br/>');
	}
 
    $templine = '';
  }
}
 echo "Tables imported successfully";
?>
 