关于php导入excel文件到mysql数据库的问题

superxiaoq 2012-04-11 09:23:37
弹出的错误:Deprecated: Assigning the return value of new by reference is deprecated in E:\source\student\reader.php on line 261

Warning: require_once(../Spreadsheet/Excel/oleread.php) [function.require-once]: failed to open stream: No such file or directory in E:\source\student\reader.php on line 31

Fatal error: require_once() [function.require]: Failed opening required '../Spreadsheet/Excel/oleread.php' (include_path='.;C:\php5\pear') in E:\source\student\reader.php on line 31


<?php
require_once 'reader.php'; // ExcelFile($filename, $encoding); $data = new Spreadsheet_Excel_Reader(); // Set output Encoding. $data->setOutputEncoding('gbk');
//"data.xls"是指要导入到mysql中的excel文件
$fileAddress=$_GET['outFile'];
$data->read('$fileAddress');
@ $db = mysql_connect('localhost', 'root', '') or
die("Could not connect to database.");//连接数据库
mysql_query("set names 'gbk'");//输出中文
mysql_select_db('student'); //选择数据库
error_reporting(E_ALL ^ E_NOTICE);
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
//以下注释的for循环打印excel表数据
/*
for ($j = 1; $j < = $data->sheets[0]['numCols']; $j++) {
echo """.$data->sheets[0]['cells'][$i][$j]."",";
}
echo "n";
*/
//以下代码是将excel表数据【3个字段】插入到mysql中,
$sql = "insert into studentmessage (ksh,xh,xm,xb,banj,nj,xib) values('".
$data->sheets[0]['cells'][$i][1]."','".
$data->sheets[0]['cells'][$i][2]."','".
$data->sheets[0]['cells'][$i][3]."','".
$data->sheets[0]['cells'][$i][4]."','".
$data->sheets[0]['cells'][$i][5]."','".
$data->sheets[0]['cells'][$i][6]."','".
$data->sheets[0]['cells'][$i][7]."')";
$res = mysql_query($sql);
}
?>

read.php和这个文件在同一路径下
...全文
398 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
一起混吧 2012-04-11
  • 打赏
  • 举报
回复
先传到csdn相册里面。再插入相册图片即可。
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
不会上传图片
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
我的权限貌似没有问题吧
一起混吧 2012-04-11
  • 打赏
  • 举报
回复
window下文件/文件夹的权限也不会改吗? win7的话赋予everyone 可读/可写的权限。
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
我是windows系统
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
恩,高手这个咋改呢?看网上也是这么说的,但是没说清楚咋改?
一起混吧 2012-04-11
  • 打赏
  • 举报
回复
没有可读权限。改改文件权限。
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
The filename $fileAddress is not readable现在就这么一句提示了
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复
恩 这个php文件和Spreadsheet文件夹是同级目录
一起混吧 2012-04-11
  • 打赏
  • 举报
回复
Spreadsheet与当前文件在同级目录? 如果是则改为: ./Spreadsheet/Excel/oleread.php

2:去掉 & 试试。

superxiaoq 2012-04-11
  • 打赏
  • 举报
回复

Deprecated: Assigning the return value of new by reference is deprecated in E:\source\student\reader.php on line 261
The filename $fileAddress is not readable

现在就这个错误了,应该在read()里面写一个xls的文件,但是我获得那个文件的路径的绝对路径然后写里面

<input type="file" id="outFile"style="margin:10px 0px 0px 50px" />
<input type="button" value="导入" id="printButton" style="margin-left:20px;" />


$("#printButton").click(function(){
var outFile=$("#outFile").val();
location.href="outFile.php?outFile="+outFile;
})
superxiaoq 2012-04-11
  • 打赏
  • 举报
回复

* Some basic initialisation
*/
function Spreadsheet_Excel_Reader()
{
$this->_ole =& new OLERead();//261行
$this->setUTFEncoder('iconv');
}

// }}}
// {{{ setOutputEncoding()

我的路径应该怎么改呢?我都放在同一文件夹下面了
一起混吧 2012-04-11
  • 打赏
  • 举报
回复
包含时路径错了。 不知道其中261行又是哪行?

20,396

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧