我使用带有以下代码的phpExcel库从xls文件中读取了一些数据:
$fisierInbound = "inbound.xls";
callsInbound();
function callsInbound() {
global $fisierInbound;
global $current;
global $con;
$identify = PHPExcel_IOFactory::identify('daily/' . $fisierInbound);
$objReader = PHPExcel_IOFactory::createReader($identify);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load('daily/' . $fisierInbound);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
//$objWorksheet = $objPHPExcel->getActiveSheet();
$query = mysqli_query($con, "SELECT * FROM users WHERE tip_user='agent' AND NOT (departament='online')");
while($usr = mysqli_fetch_array($query)) {
$data[] = $usr;
}
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$worksheetTitle = $worksheet->getTitle();
$highestRow = $worksheet->getHighestRow(); // e.g. 10
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$dataCalls = $worksheet->getCellByColumnAndRow(2, 2)->getValue();
$dataSubstr = substr($dataCalls, 53);
echo $dataSubstr;
foreach ($data as $db) {
for ($row = 6; $row <= $highestRow; ++ $row) {
$marca = $worksheet->getCellByColumnAndRow(3, $row)->getValue();
$nr = $worksheet->getCellByColumnAndRow(4, $row)->getValue();
if($db['marca'] == $marca) {
mysqli_query($con, "INSERT INTO dailycalls(data, nr, departament, oras, tip, id_user)
VALUES('$dataSubstr', '$nr', '" . $db['departament'] . "', '" . $db['oras'] . "', 'inbound', '" . $db['id'] . "')");
}
}
}
}
}
它在localhost上运行得很完美但是如果我从主机运行它我会收到Chrome错误没有收到数据
无法加载网页,因为服务器未发送任何数据。 错误代码:ERR_EMPTY_RESPONSE
但查询运行(数据插入到数据库中)。什么似乎是问题?
谢谢!