include database file is not working in php when create excel reports
<p>this code works properly  when i use database configuration  by my own in this file</p>

<pre><code>&lt;?php

$usernam="820674_prototype";
$passwor="fanihoja";
$hostname="fdb3.awardspace.com";

$db=mysql_connect($hostname,$usernam,$passwor)
or die("database not found");

mysql_select_db("820674_prototype",$db)
or die("data not found");
include_once("db.php");
 include_once('Worksheet.php');
  include_once('Workbook.php');

  function HeaderingExcel($filename) {
      header("Content-type: application/vnd.ms-excel");
      header("Content-Disposition: attachment; filename=$filename" );
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
      header("Pragma: public");
      }

  // HTTP headers
  HeaderingExcel('test.xls');

  // Creating a workbook
  $workbook = new Workbook("-");
  // Creating the first worksheet

  //$worksheet1-&gt;write_formula(4, 4, "= LN(2.71428)");
  //$worksheet1-&gt;write_formula(5, 4, "= SIN(PI()/2)");

  // Creating the second worksheet
  $worksheet2 =&amp; $workbook-&gt;add_worksheet();

  // Format for the headings

 $worksheet2-&gt;set_column(0,0,12);
  $worksheet2-&gt;set_column(1,1,30);
  $worksheet2-&gt;set_column(2,2,35);
  $worksheet2-&gt;set_column(3,3,13);
    $worksheet2-&gt;set_column(4,4,15);

 $result = mysql_query("SELECT * FROM user");




 $b=2;
while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
 $test1=$row[0];
  $test2=$row[1];
   $test3=$row[2];
    $test4=$row[3];

$a=0;    
 $worksheet2-&gt;write_string($b,$a,$test1);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test2);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test3);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test4);
 $a++;


$b++;
}

$worksheet2-&gt;write_string(0,0,$lace,$formatot2);
$worksheet2-&gt;write_string(0,1,$lace,$formatot2);
$worksheet2-&gt;write_string(0,2,$lac,$formatot2);

  $worksheet2-&gt;write_string(1,0,"Id",$formatot);
  $worksheet2-&gt;write_string(1,1,"Name",$formatot);
  $worksheet2-&gt;write_string(1,2,"Adress",$formatot);
  $worksheet2-&gt;write_string(1,3,"Phone Number",$formatot);
  $worksheet2-&gt;write_string(1,4,"Salary",$formatot);

  // if you are writing a very long worksheet, you may want to use
  // write_xxx() functions, instead of write() for performance reasons.



  // Calculate some statistics


  //$worksheet2-&gt;insert_bitmap(0, 0, "some.bmp",10,10);

  $workbook-&gt;close();
?&gt;
</code></pre>

<p>this code is not working when i use include but include is working in other files i am using include function here to include database file but it is not producing valid excel reports</p>

<pre><code>&lt;?php
include_once("db.php");
 include_once('Worksheet.php');
  include_once('Workbook.php');

  function HeaderingExcel($filename) {
      header("Content-type: application/vnd.ms-excel");
      header("Content-Disposition: attachment; filename=$filename" );
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
      header("Pragma: public");
      }

  // HTTP headers
  HeaderingExcel('test.xls');

  // Creating a workbook
  $workbook = new Workbook("-");
  // Creating the first worksheet

  //$worksheet1-&gt;write_formula(4, 4, "= LN(2.71428)");
  //$worksheet1-&gt;write_formula(5, 4, "= SIN(PI()/2)");

  // Creating the second worksheet
  $worksheet2 =&amp; $workbook-&gt;add_worksheet();

  // Format for the headings

 $worksheet2-&gt;set_column(0,0,12);
  $worksheet2-&gt;set_column(1,1,30);
  $worksheet2-&gt;set_column(2,2,35);
  $worksheet2-&gt;set_column(3,3,13);
    $worksheet2-&gt;set_column(4,4,15);

 $result = mysql_query("SELECT * FROM user");




 $b=2;
while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
 $test1=$row[0];
  $test2=$row[1];
   $test3=$row[2];
    $test4=$row[3];

$a=0;    
 $worksheet2-&gt;write_string($b,$a,$test1);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test2);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test3);
 $a++;
 $worksheet2-&gt;write_string($b,$a,$test4);
 $a++;


$b++;
}

$worksheet2-&gt;write_string(0,0,$lace,$formatot2);
$worksheet2-&gt;write_string(0,1,$lace,$formatot2);
$worksheet2-&gt;write_string(0,2,$lac,$formatot2);

  $worksheet2-&gt;write_string(1,0,"Id",$formatot);
  $worksheet2-&gt;write_string(1,1,"Name",$formatot);
  $worksheet2-&gt;write_string(1,2,"Adress",$formatot);
  $worksheet2-&gt;write_string(1,3,"Phone Number",$formatot);
  $worksheet2-&gt;write_string(1,4,"Salary",$formatot);

  // if you are writing a very long worksheet, you may want to use
  // write_xxx() functions, instead of write() for performance reasons.



  // Calculate some statistics


  //$worksheet2-&gt;insert_bitmap(0, 0, "some.bmp",10,10);

  $workbook-&gt;close();
?&gt;
</code></pre>
