// Name of the file$filename = 'churc.sql';// MySQL host$mysql_host = 'localhost';// MySQL username$mysql_username = 'root';// MySQL password$mysql_password = '';// Database n " /> 亚洲激情小视频,欧美黑人粗大,xxxx日韩

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP處理SQL腳本文件導入到MySQL的代碼實例

復制代碼 代碼如下:<?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";
?>

php技術PHP處理SQL腳本文件導入到MySQL的代碼實例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 吕梁市| 闸北区| 扶余县| 林甸县| 宜黄县| 大石桥市| 中山市| 如东县| 绩溪县| 河东区| 革吉县| 铜山县| 湘阴县| 晋中市| 澄迈县| 建德市| 宝山区| 和林格尔县| 房产| 神池县| 新泰市| 五常市| 泰宁县| 呼伦贝尔市| 辽阳市| 共和县| 礼泉县| 湖口县| 宁晋县| 宜兰市| 东明县| 祁连县| 公主岭市| 尉犁县| 乌审旗| 水城县| 加查县| 马边| 宁蒗| 习水县| 乐陵市|