php逐行读取txt并导入数据库
php逐行读取txt并导入数据库 br / 转载: a href=http://www.tongqiong.com/read.php?tid-11-ds-1.html rel=nofollowhttp://www.tongqiong.com/read.php?tid-11-ds-1.html/a
php逐行读取txt并导入数据库
转载: http://www.tongqiong.com/read.php?tid-11-ds-1.html
转载: http://www.tongqiong.com/read.php?tid-11-ds-1.html
<?php
//作者:www.tongqiong.com
set_time_limit(13600); //设置时间
$conn=mysql_connect('localhost','root',''); //连接数据库
mysql_select_db('tongqiong',$conn);
mysql_query("SET NAMES utf8");
$fp_in = fopen('F:/sql/www.tongqiong.com.txt', "r");
while (!feof($fp_in)) {
$line = fgets($fp_in);
//$u=explode('# ', $line);//如果有分割
mysql_query("INSERT INTO `user` (title)VALUES('trim($line)')",$conn);
}
echo 'OK';
//作者:www.tongqiong.com
?>
- 上一篇:php 删除mysql数据库的重复记录
- 下一篇:PHPExcel代码
精彩图集
精彩文章






