MySql 下的命令load data local infile "c:\\这样的.TXT " into table testing (ip,ck)

解决方案 »

  1.   

    load data local infile "http://www.rjqimo.com/ipdata.txt" into table testing (ip,ck)我去试下看...先谢谢楼上了
      

  2.   

    <?$a = file('data.txt');foreach ($a as $k){
    $s = explode(' ',$k);
    echo '<pre>';
    print_r ($s);
    echo '</pre>';
    }?>
      

  3.   

    服务器不支持MYSQL load data  命令怎么办啊???? 
      

  4.   

    <?
    //main
    $hostname = "localhost";
    $user = "root";
    $pw= "root";
    $database= "yourdatabase";

    $db = new PDO('mysql:host='.$hostname.';dbname='.$database, $user, $pw);
    $db->exec("SET NAMES 'utf8'");

    $fhand = fopen("http://127.0.0.1/php/data.txt","r");

    $todata = array();
    while($lineinfo = getinfo()){
    $lineinfo=iconv("GB2312","UTF-8",$lineinfo);
    $lineinfo = explode(" ", $lineinfo);
    $todata[]= $lineinfo;
    }
    $todata=daddslashes($todata);
    savetodatabase($todata,$db);



    function savetodatabase($todata,$db){
    $sql="INSERT INTO `yourtable` (`one`,`two`,`three`,`four`) VALUES";
    foreach($todata as $array){
    $sql.="(";
    foreach($array as $value){
    $sql.="'".$value."',";
    }
    $sql=substr($sql, 0, -1);  
    $sql.="),";
    }
    $sql=substr($sql, 0, -1);

    //echo $sql;
    echo $db->exec($sql);
    }

    function getinfo(){
    global $fhand;
    if(feof($fhand)){
    return false;
    fclose($fhand);
    }
    $line = fgets($fhand);
    return $line;
    }

    function daddslashes($string, $force = 0) 
    {
    !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
    if(!MAGIC_QUOTES_GPC || $force)
    {
    if(is_array($string))
    {
    foreach($string as $key => $val) 
    {
    $string[$key] = daddslashes($val, $force);
    }

    else 
    {
    $string = addslashes($string);
    }
    }
    return $string;
    }
    ?>