请问如何把文本文件导入到MYSQL中 送100分 MySql 下的命令load data local infile "c:\\这样的.TXT " into table testing (ip,ck) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 load data local infile "http://www.rjqimo.com/ipdata.txt" into table testing (ip,ck)我去试下看...先谢谢楼上了 <?$a = file('data.txt');foreach ($a as $k){ $s = explode(' ',$k); echo '<pre>'; print_r ($s); echo '</pre>'; }?> 服务器不支持MYSQL load data 命令怎么办啊???? <? //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; }?> 弱弱的问一下CENTOS下PHP.INI的改动怎么没有效果 紧急求助,图片删除的文件! cookie问题 新手问一下PHP类的使用方法 我在phpmyadmin中修改mysql密码后,应再也无法登录了,如何办呢? function.inc干扰gd的生成图片显示? iis下php如何联接mysql4.1.11 如何在数据表中随机抽取不同的10条记录 回来看一看,顺便问一个简单问题! 求大神帮忙解释一段php代码,关于crypt加密 PHP web service 如何使用 disco文件 下载类
$s = explode(' ',$k);
echo '<pre>';
print_r ($s);
echo '</pre>';
}?>
//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;
}
?>