Search
 
SCRIPT & CODE EXAMPLE
 

PHP

big database file into database php

<?php

// Name of the file
$filename = 'churc.sql';
// MySQL host
$mysql_host = 'localhost';
// MySQL username
$mysql_username = 'root';
// MySQL password
$mysql_password = '';
// Database name
$mysql_database = 'dump';

// Connect to MySQL server
mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
// Select database
mysql_select_db($mysql_database) 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
    mysql_query($templine) or print('Error performing query '<strong>' . $templine . '': ' . mysql_error() . '<br /><br />');
    // Reset temp variable to empty
    $templine = '';
}
}
 echo "Tables imported successfully";
?>
Comment

PREVIOUS NEXT
Code Example
Php :: get row ezSql | select on ezSql 
Php :: get session token in wp_login hook 
Php :: PHP SimpleXML - Get Node/Attribute Values 
Php :: keep value after submit php 
Php :: laravel-websockets 403 forbidden error 
Php :: Limiter la révision des articles WordPress 
Php :: learndash logo link 
Php :: leggere file su piu righe php 
Php :: simple using mdb with php script PDO 
Php :: laravel migrate patth 
Php :: namespace autoload php 
Php :: php accounting ledger 
Php :: validation sellphone laravel 
Php :: Never return type - PHP 8.1 
Php :: echo $path not showing composer 
Php :: date selct option php 
Php :: Condition 
Php :: eager load relationships on an existing model in route laravel 
Php :: all locales php 
Php :: wp_remote_post decode data 
Php :: installing php storm version 20 in ubuntu 
Php :: barryvdh laravel dompdf pages total 
Php :: cashier mollie 
Php :: Solution for unseting an array 
Php :: chr (PHP 4, PHP 5, PHP 7, PHP 8) chr — Generate a single-byte string from a number 
Php :: laravel class is not recognized in tinker 
Php :: disableTimeRanges 
Php :: php group subarrays by column key 
Php :: how to know app_basepath 
Php :: command line that convert html to php file 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =