#36894 [Opn->Bgs]: blank lines between php sections output in echo of binary data from MySQL

From: Date: Tue, 28 Mar 2006 15:25:33 +0000
Subject: #36894 [Opn->Bgs]: blank lines between php sections output in echo of binary data from MySQL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95016@lists.php.net to get a copy of this message
ID: 36894 Updated by: tony2001@php.net Reported By: mickey dot martin at alcatel dot com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Windows XP PHP Version: 5.1.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2006-03-28 17:20:13] mickey dot martin at alcatel dot com Description: ------------ When outputting a binary data file from MySQL, erronious newlines are being inserted into the file when there are multiple sections of php code (in seperate php tags) and there are blank spaces in between the sections. Reproduce code: --------------- <?php require_once('../Connections/TestFiles.php'); ?> <?php $colname_DnldFile = "-1"; if (isset($_GET['id_files'])) { $colname_DnldFile = (get_magic_quotes_gpc()) ? $_GET['id_files'] : addslashes($_GET['id_files']); } mysql_select_db($database_TestFiles, $TestFiles); $query_DnldFile = sprintf("SELECT bin_data, filename, filesize, filetype FROM tbl_files WHERE id_files = %s", $colname_DnldFile); $DnldFile = mysql_query($query_DnldFile, $TestFiles) or die(mysql_error()); $row_DnldFile = mysql_fetch_assoc($DnldFile); $totalRows_DnldFile = mysql_num_rows($DnldFile); $type = $row_DnldFile['filetype']; $name = $row_DnldFile['filename']; $data = $row_DnldFile['bin_data']; $size = $row_DnldFile['filesize']; header("Content-type: $type"); header("Content-length: $size"); header("Content-Disposition: attachment; filename=\"$name\""); header("Content-Description: PHP Generated Data"); echo $data; ?> <?php mysql_free_result($DnldFile); ?> Expected result: ---------------- I expect to download the file from MySQL and be able to open and read it in the proper application. Actual result: -------------- When executing this code with a plain text file, a blank line is being inserted at the beginning and end of the file. When executing with a binary file (MS Word document) the file is un-readable. Removing the line between the php tags: <?php require_once('../Connections/TestFiles.php'); ?> <?php $colname_DnldFile = "-1"; ... ?> <?php mysql_free_result($DnldFile); ?> causes the proper file to output. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36894&edit=1

« previous php.bugs (#95016) next »