I am trying to generate an Excel document from a database using PHP. A group called Darkstreak developed a function list to do this. Darkstreak's Website shows how to use his functions to accomplish this.
I have followed his coding only I slighly modified it to get data from my database:
<?php
$link = mysql_connect("localhost", username, password);
mysql_select_db (texasdeltachi_org);
$query = "SELECT * FROM guestlist ORDER BY lname, fname";
$result = mysql_query ($query) or die ("Query failed");
require_once("functions.php");
deliveryfmt_initialize();
deliveryfmt_set_format('xls', false);
header('Content-Type: '.deliveryfmt_mimetype()); header('Content-Disposition: attachment;filename="guestlist.'.deliveryfmt_format_extension().'"'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT');
$nocache = 'Cache-Control: no-cache'; // HTTP/1.1
if ($SERVER_PROTOCOL == 'HTTP/1.0') { $nocache = 'Pragma: no-cache'; }
header($nocache);
header('Content-Transfer-Encoding: binary');
deliveryfmt_header();
$colnames = array(1=>'lastname', 2=>'firstname');
deliveryfmt_set_column_names($colnames);
while($row = mysql_fetch_array($result))
{
$data = array('lastname'=>$row["lname"], 'firstname'=>$row["fname"]);
deliveryfmt_put_array($data);
}
mysql_close($link);
deliveryfmt_trailer();
$buffer = deliveryfmt_finish();
echo $buffer;
?>
[/SIZE]
Thats pretty simple, and I follow what he does down to a T. It should work like that, but it doesn't. I get the following errors:
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 13
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 14
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 15
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 16
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 19
Warning: Cannot add header information - headers already sent by (output started at /home/bkputh/texasdeltachi-www/act/f/gen.php:2) in /home/bkputh/texasdeltachi-www/act/f/gen.php on line 20
LASTNAME FIRSTNAMEAltschul MattCarter MattDalton James Desai Kasul Grove Dave Krug Ryan LouAnthony