dsstlsqt696435 2014-08-17 08:06
浏览 79

NetworkError:500内部服务器错误 - http://

I am trying to export the search data into excel but i am getting an error NetworkError: 500 Internal Server Error - http:// can any one tell me how to fix this error? Below is my code. Can anyone tell me how to fix this error, where i went wrong? It's not exporting it opens cmsexp_to_excel.php, which is blank in firebug it shows an error.

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();
?>
  • 写回答

1条回答 默认 最新

  • douhun7609 2014-08-17 08:25
    关注
       $sheet->setCellValueByColumnAndRow(4,$offset,$row['country1']);
    

    Should be

         $sheet->setCellValueByColumnAndRow(4,$offset,$row['country3']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染