From: david dot nicholls at camden dot gov dot uk
Operating system: Windows 2000
PHP version: 4.3.3
PHP Bug Type: Output Control
Bug description: echo output ok in cmd but not in web browser
Description:
------------
Data sourced from a CSV file does not echo when a script is invoked via
web browser from IIS 5 but does output when invoked from a cmd via
php.exe.
A simple change of commenting out the line
$csv = get_csv ($csvname);
and uncommenting
// $csv = array ($line,$line,$line);
produces output in the browser and the console as expected
I have checked the CSV file and the data only contains alphanumeric
characters.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
echo "Read CSV and Output result<P>";
/*** CSV INPUT ***/
$csvname = '\\\\camden-pdc\\logs$\\logon.csv';
echo "Loading CSV from $csvname<P>";
$csv = get_csv ($csvname);
$line = array(1,"a",3,4,"b",6,7,8,9);
// $csv = array ($line,$line,$line);
echo "Got CSV Printing CSV<P>";
foreach ($csv as $field)
{
$strecho = $field[2]."\t\t".$field[5]."<P>\n\r"; echo
addslashes($strecho);
}
function get_csv($filename, $delim=',')
{
$row = 0;
$dump = array();
echo "get_csv function<P>";
$f = fopen ($filename,"r");
$size = filesize($filename)+1;
while ($data = fgetcsv($f, $size, $delim)) {
$dump[$row] = $data;
$row++;
}
fclose ($f);
return $dump;
}
?>
Expected result:
----------------
Console Sample
C:\Inetpub\wwwroot>php av.php
Content-type: text/html
X-Powered-By: PHP/4.3.3
Read CSV and Output result<P>Loading CSV from
\\camden-pdc\logs$\logon.csv<P>get
_csv function<P>Got CSV Printing CSV<P>X039482 ENVIRONMENT<P>
X034800 HOUSING<P>
W024792 LEISURE<P>
X030990 ENVIRONMENT<P>
X036399 ITD<P>
X041971 ENVIRONMENT<P>
X033233 ENVIRONMENT<P>
X031711 ENVIRONMENT<P>
X036189 ENVIRONMENT<P>
X047548 HOUSING<P>
X035445 ENVIRONMENT<P>
X039397 HOUSING<P>
X033244 ENVIRONMENT<P>
X026376 ENVIRONMENT<P>
Actual result:
--------------
HTML Output
1 Read CSV and Output result<P>Loading CSV from
\\camden-pdc\logs$\logon.csv<P>get_csv function<P>Got CSV Printing CSV<P>
--
Edit bug report at http://bugs.php.net/?id=25808&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25808&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25808&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25808&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25808&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25808&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25808&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25808&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25808&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25808&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25808&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25808&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25808&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25808&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25808&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25808&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25808&r=float