[英]NetworkError: 500 Internal Server Error - http://
我正在嘗試將搜索數據導出到excel,但出現錯誤NetworkError: 500 Internal Server Error - http://
誰能告訴我如何解決此錯誤? 下面是我的代碼。 誰能告訴我如何解決這個錯誤,我哪里出錯了? 它不導出,而是打開cmsexp_to_excel.php,在螢火蟲中為空白,它顯示錯誤。
Filterdata.php
<?php
$mediaexport=$_GET["media"];
?>
<form action = "cmsexp_to_excel.php" method = "post">
<input checked type='checkbox' name="media" value="<?php echo $mediaexport;?>" style='visibility:hidden' >
<input type="image" value="" src="/img/export.png" class="export" style='margin:0 5px -9px 183px;cursor:pointer;'>
</form>
cmsexp_to_excel.php
<?php
require_once 'Classes/PHPExcel.php';
$mediaexport=$_GET['media'];
$date = date('d.m.Y', time());
$sql = "SELECT DISTINCT contact.`id` , contact.`contactgroup` , contact.`media` , contact.`media2` , contact.`email1` , contact.`nationality` , contact.`country3` , contact.`twon` , contact.`area` , contact.`gender` , contact.`married` , contact.`children` , contact.`driverslicense`
FROM contact";
if ($media !="" && $media !="Empty" && $media == "sms" ){
$sql.=" and media = '".$media."'";
}
if ($media !="" && $media !="Empty" && $media == "email" ){
$sql.=" and media2 = '".$media."'";
}
if ($media !="" && $media !="Empty" && $media == "sms,email" ){
$sql.=" and media = 'sms' and media2 = 'email' ";
}
$queryRes = mysql_query($sql);
// start creating excel
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$sheet = $objPHPExcel->getActiveSheet();
// your data
$sheet->setCellValueByColumnAndRow(0,1,'Contact group');
$sheet->setCellValueByColumnAndRow(1,1,'Media');
$sheet->setCellValueByColumnAndRow(2,1,'E-mail');
$sheet->setCellValueByColumnAndRow(3,1,'Nationality');
$sheet->setCellValueByColumnAndRow(4,1,'Country');
$sheet->setCellValueByColumnAndRow(5,1,'City');
$sheet->setCellValueByColumnAndRow(6,1,'Area');
$sheet->setCellValueByColumnAndRow(7,1,'Gender');
$sheet->setCellValueByColumnAndRow(8,1,'Married');
$sheet->setCellValueByColumnAndRow(9,1,'Children');
$sheet->setCellValueByColumnAndRow(10,1,'Drivers license');
// start list
$offset = 2;
$total_cost = 0;
$total_sms = 0;
while( $row = mysql_fetch_assoc($queryRes)){
$sheet->setCellValueByColumnAndRow(0,$offset,$row['contactgroup']);
$sheet->setCellValueByColumnAndRow(1,$offset,$row['media']);
$sheet->setCellValueByColumnAndRow(2,$offset,$row['email1']);
$sheet->setCellValueByColumnAndRow(3,$offset,$row['nationality']);
$sheet->setCellValueByColumnAndRow(4,$offset,$row['country1']);
$sheet->setCellValueByColumnAndRow(5,$offset,$row['twon']);
$sheet->setCellValueByColumnAndRow(6,$offset,$row['area']);
$sheet->setCellValueByColumnAndRow(7,$offset,$row['gender']);
$sheet->setCellValueByColumnAndRow(8,$offset,$row['married']);
$sheet->setCellValueByColumnAndRow(9,$offset,$row['children']);
$sheet->setCellValueByColumnAndRow(10,$offset,$row['driverslicense']);
$offset++;
}
$attachment_name= "Export-DB$date";
//OUTPUT
header("Content-Type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=$attachment_name.xls");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit();
?>
$sheet->setCellValueByColumnAndRow(4,$offset,$row['country1']);
應該
$sheet->setCellValueByColumnAndRow(4,$offset,$row['country3']);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.