<form action="import.php" method="POST" enctype="multipart/form-data"> <input type="file" name="image" class="ed"><br /> <input type="submit" value="Save" /> </form>
<?php // new data $file=$_FILES['image']['tmp_name']; $filename=$_FILES["image"]["name"]; $mysql_host = 'localhost'; $mysql_username = 'root'; $mysql_password = ''; $mysql_database = 'tutorials'; // Connect to MySQL server mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error()); // Select database // Temporary variable, used to store current query $templine = ''; // Read in entire file // Loop through each line foreach ($lines as $line) { // Skip it if it's a comment 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 { // Perform the query mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />'); // Reset temp variable to empty $templine = ''; } } echo '<div style="text-align: center; margin-top: 50px;">'; echo "Tables imported successfully<br>"; echo 'form'.$dir.'/' .$filename .'To '.$mysql_database.'<br>'; echo '<a href="../index.php">Back</a>'; echo '</div>'; ?>