一段PHP代码结果有关问题

php中文网
发布: 2016-06-13 10:18:15
原创
1083人浏览过

一段PHP代码结果问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $DBserver = "localhost";$DBname = "lookdb";$DBuser = "root";$DBpassword = "";$con = mysql_connect("localhost","root","");mysql_select_db("lookdb");function listDir($dir){    if (is_dir($dir)){        if($dh = opendir($dir)){            while(($file = readdir($dh))!== false){                if((is_dir($dir."/".$file))&&$file!="."&&$file!=".."){                    echo "<b><font color='red'>文件名:</font></b>",$file,"<br><hr>";                    listDir($dir."/".$file."/");                }                else{                    if($file!="."&&$file!=".."){                        echo $file." ";                        $arr = explode(" ",$file);                                                print_r($arr);                                                $sql = "insert into pdfcontents (pdf_title) value ('{$arr}')";                    }                }            }            closedir($dh);        }    }    return ($file);}listDir("C:/AEED/PHPnow/htdocs/2003Z/nz/");?>
登录后复制



结果:
nz01.pdf Array ( [0] => nz01.pdf ) nz02.pdf Array ( [0] => nz02.pdf ) nz03.pdf Array ( [0] => nz03.pdf ) nz04.pdf Array ( [0] => nz04.pdf ) nz05.pdf Array ( [0] => nz05.pdf ) nz06.pdf Array ( [0] => nz06.pdf ) nz07.pdf Array ( [0] => nz07.pdf ) nz08.pdf Array ( [0] => nz08.pdf ) nz09.pdf Array ( [0] => nz09.pdf ) nz10.pdf Array ( [0] => nz10.pdf ) nz11.pdf Array ( [0] => nz11.pdf ) nz12.pdf Array ( [0] => nz12.pdf ) nz13.pdf Array ( [0] => nz13.pdf ) nz14.pdf Array ( [0] => nz14.pdf ) nz15.pdf Array ( [0] => nz15.pdf ) nz16.pdf Array ( [0] => nz16.pdf ) nz17.pdf Array ( [0] => nz17.pdf ) nz18.pdf Array ( [0] => nz18.pdf ) nz19.pdf Array ( [0] => nz19.pdf ) nz20.pdf Array ( [0] => nz20.pdf ) nz21.pdf Array ( [0] => nz21.pdf ) nz22.pdf Array ( [0] => nz22.pdf ) nz23.pdf Array ( [0] => nz23.pdf ) nz24.pdf Array ( [0] => nz24.pdf ) nz25.pdf Array ( [0] => nz25.pdf ) nz26.pdf Array ( [0] => nz26.pdf ) nz27.pdf Array ( [0] => nz27.pdf ) nz28.pdf Array ( [0] => nz28.pdf ) nz29.pdf Array ( [0] => nz29.pdf ) nz30.pdf Array ( [0] => nz30.pdf ) nz31.pdf Array ( [0] => nz31.pdf ) nz32.pdf Array ( [0] => nz32.pdf ) nz33.pdf Array ( [0] => nz33.pdf ) nz34.pdf Array ( [0] => nz34.pdf ) nz35.pdf Array ( [0] => nz35.pdf ) nz36.pdf Array ( [0] => nz36.pdf ) nz37.pdf Array ( [0] => nz37.pdf ) nz38.pdf Array ( [0] => nz38.pdf ) nz39.pdf Array ( [0] => nz39.pdf ) nz40.pdf Array ( [0] => nz40.pdf ) nz41.pdf Array ( [0] => nz41.pdf ) nz42.pdf Array ( [0] => nz42.pdf ) nz43.pdf Array ( [0] => nz43.pdf ) nz44.pdf Array ( [0] => nz44.pdf ) nz45.pdf Array ( [0] => nz45.pdf ) nz46.pdf Array ( [0] => nz46.pdf ) nz47.pdf Array ( [0] => nz47.pdf ) nz48.pdf Array ( [0] => nz48.pdf ) nz49.pdf Array ( [0] => nz49.pdf ) nz50.pdf Array ( [0] => nz50.pdf ) nz51.pdf Array ( [0] => nz51.pdf ) nz52.pdf Array ( [0] => nz52.pdf ) nz53.pdf Array ( [0] => nz53.pdf ) nz54.pdf Array ( [0] => nz54.pdf ) nz55.pdf Array ( [0] => nz55.pdf ) nz56.pdf Array ( [0] => nz56.pdf ) nz57.pdf Array ( [0] => nz57.pdf ) nz58.pdf Array ( [0] => nz58.pdf ) nz59.pdf Array ( [0] => nz59.pdf ) nz60.pdf Array ( [0] => nz60.pdf ) 

我只是想把目录里的文件名都分条存入数据库呀。这样存不进去.

------解决方案--------------------
呵呵,看错眼啦

$sql = "insert into pdfcontents (pdf_title) value ('{$arr}')";

$arr是explode的数组吧,不带这样执行的,,你希望保存什么吧

相关标签:
pdf
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号