数据库中设置好一个表txt,包含五个字段。
txt (id, txt1, txt2, txt3, txt4)Txt文件中包含的内容是也是5个[33,1,"中国","陕西","宝鸡"]1000多的文件已获得文件名主名:pageID[0]占位
$pageID =array(0,1970634101,1987477110,……………………);如何用PHP把1000多个.txt插入到MYSQL数据库中。
txt (id, txt1, txt2, txt3, txt4)Txt文件中包含的内容是也是5个[33,1,"中国","陕西","宝鸡"]1000多的文件已获得文件名主名:pageID[0]占位
$pageID =array(0,1970634101,1987477110,……………………);如何用PHP把1000多个.txt插入到MYSQL数据库中。
解决方案 »
- 怎么将C#中有BitConverter.Tostring的数据转化成字符串
- 如何对站内搜索结果分页
- PHP简单问题,请大家指教一下...
- 关于验证码的问题!无法生成图片,显示乱码。
- PHP怎样读取WSDL接口参数和回调给对方?
- 诚心求教! 有关php在Linux中运行的问题...
- 求一个php新闻系统(找了很久没有找到合适的)
- 求源代码:计时功能
- php获取 form表单下编辑器输入的内容,其编辑器是iframe引入的
- 学了一个月PHP,发现编程语言是国外的,开发工具是国外的,只有编程的人是中国人
- linux VirtualHost 目录的简单问题,在线等
- 处理表单-如何获得来自html表单输入的数值
if ($handle = opendir('D:\\a\\')) //设置文件路径
{
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { //读取目录下的文件
$lines = file('D:\\a\\'.$file);
foreach ($lines as $fline)
{
$newfile= explode(',', $fline); //分割后存入数组
// insert into table() value($newfile[0]...$newfile[4]);
}
}
}
closedir($handle);
}
?>
超時的問題,只要讓程式無限時進行,或直接php.exe phpfile就行了
內存問題的話,只能看你的機器了.如果可以的話,建議你在服務器上進行
mysql_query("set names 'utf8'");if (!$con)
{
die('不能连接到数据库: ' . mysql_error());
}mysql_select_db("Exam", $con);if ($handle = opendir('ExamBase')) //设置文件路径{
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { //读取目录下的文件
$lines = file('ExamBase/'.$file);
foreach ($lines as $fline)
{
$b = str_replace("[","",$fline);
$a = str_replace("]","",$b);
$c = str_replace("\"","", $a);
$newfile= explode(',', $c); //分割后存入数组
$sql="INSERT INTO myExam(myExamID,myExamTx, myExamCnt, myExamImg, myExamDaRight) values ('$newfile[0]','$newfile[1]','$newfile[2]','$newfile[3]','$newfile[4]')";
if (!mysql_query($sql,$con))
{
die('错误: ' . mysql_error());
}
}
}
}
closedir($handle);
}
mysql_close($con)
?>