First off, I'm by no means new to PHP, or sending headers. However, I'm getting the following error:
Warning: Cannot modify header information - headers already sent in /var/www/oraviewer/download/scripts/start.inc on line 30
Warning: Cannot modify header information - headers already sent by (output started at /var/www/oraviewer/download/scripts/start.inc:30) in /var/www/oraviewer/download/scripts/start.inc on line 31
Warning: Cannot modify header information - headers already sent by (output started at /var/www/oraviewer/download/scripts/start.inc:30) in /var/www/oraviewer/download/scripts/start.inc on line 32
3 errors because I'm trying to send 3 headers.
I've scoured every file included, checked them for any possible sending of headers, newlines, text, etc. and nothing.
I'm used to this sort of error telling you where the first bit of print came from (see the second 2 errors to see what I mean) but the first isn't telling me anything.
To the best of my knowledge, none of these files have changed since I last had them working, and using a backup copy, they work fine. Unfortunately, if I replace them with the backup files, the problem persists. I would post the files, but there's about a half dozen of them, amounting to a couple hundred lines.
So, my main question: What could be causing this, and how would I track down where it's coming from?
EDIT: The 3 lines at 30-32, whcih are the specific headers being printed
header('Content-Type: application/octet-stream');
header('Content="text/plain;charset=ISO-8859-1"');
header('Content-Disposition: attachment; filename="'.$fileName.'"');
If I comment one out, the errors start at the next one, so I know it's something before these.
The code before the start.inc in getExtract.php file:
<?php
include_once "start.inc";
The start.inc file:
<?php
$extract = $_GET['extract'];
$debug = $_GET['debug'];
include "../../lib/conf.inc";
include $mainsitedir."/lib/db_connect.inc";
include $mainsitedir."/lib/utils.inc";
include "../queries/get_output_file_name.php";
$db_link = connect_db();
$query = "SELECT * FROM extract_wxo_list WHERE extract_id='{$_GET['extract']}'";
$file = db_get_row(db_query($db_link, $query));
$fileName = $file['OUTPUT_FILE_NAME'];
if (!empty($_GET['versiondate'])) {
$sql = "SELECT * FROM version_history WHERE version_start_date = '{$_GET['versiondate']}'";
$vquery = db_query( $db_link, $sql );
if ($vrow = db_get_row($vquery)) {
$splitName = preg_split("/[.]/", $fileName, 2);
$fileName = $splitName[0].'_'.str_replace(".", "", $vrow['VERSION']).'.'.$splitName[1];
}
}
if ( $_GET['debug'] ) {
echo "$fileName<br /><pre>";
} else {
header('Content-Type: application/octet-stream');
header('Content="text/plain;charset=ISO-8859-1"');
header('Content-Disposition: attachment; filename="'.$fileName.'"');
}
date_default_timezone_set('UTC');
?>
The 4 includes near the top are the same in another few files. They also use headers in a similar, but less generic, fashion, so I can rule them out as the cause.