php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25808 echo output ok in cmd but not in web browser
Submitted: 2003-10-09 12:36 UTC Modified: 2003-10-10 06:45 UTC
From: david dot nicholls at camden dot gov dot uk Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.3 OS: Windows 2000
Private report: No CVE-ID: None
 [2003-10-09 12:36 UTC] david dot nicholls at camden dot gov dot uk
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>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-09 12:45 UTC] wez@php.net
My theory:

Your command prompt runs under your credentials, and you
have permission to access the network share.

IUSR_<machinename>, the user under which IIS is running,
does not have permissions to access the share.

However, I would expect to see a warning in that case.
 [2003-10-09 12:48 UTC] wez@php.net
Just thought that it could be that filesize() is returning
-1 for the csv file; -1 + 1 == 0, which means that the fgetcsv() function is returning no data at all, because you
have asked it for none.

Check the permissions on the file, and check the return value.  You probably don't need the filesize() call at all; just use a reasonable line length (1024 seems ok to me).

 [2003-10-10 05:36 UTC] david dot nicholls at camden dot gov dot uk
Your theory was correct disabled anonmymous access (only Windows Authenticated allowed). Thanks for your help.

No warning message was given which I guess is a bug after all.

Many thanks
 [2003-10-10 05:56 UTC] david dot nicholls at camden dot gov dot uk
Ignore the 'bug' its user error!

Just checked my php.ini and found display_errors had become set to off something must have gone astray when downgrading back to 4.3.3 from 5.0.2-dev
 [2003-10-10 06:45 UTC] wez@php.net
I thought it might that too. :-)
User error, so marking as bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC