php逐行读取txt并导入数据库
程序员文章站
2022-05-20 23:43:35
...
跳至
<?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 ?>
上一篇: Java泛型介绍