fgets fails after fopen succeeds -- cleaned up for better digestion.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I removed the "r+", since that not my intended mode.
File Handle is 1 after the fopen call.
fgets, feof, and fclose fail on $fh. (So does fread, FWIW).
The file exists. fopen fails if it is moved.
 *Code:*
<?php
function make_link_list($name="") {

print './outside/'.$name.'.txt';
?>
<ul>
<?
$fh=fopen('./outside/'.$name.'.txt', 'r') || die("Cannot open file"); 
print "File Handle: ".$fh;
for ($line = fgets($fh, 1000); ! feof($fh); $line = fgets($fh, 1000)) {
if (!$line) break ;
$line = trim($line);
if(strlen($line) > 0) {
print '<li>' . $line ."</li>\n";
}
}
?>
</ul>
<?
fclose($fh);
}
make_link_list("index");
?>
 *Output:*
./outside/index.txt 

   File Handle:1
   *Warning*: fgets(): supplied argument is not a valid stream resource 
   in *C:\Program Files\Apache 
   Group\Apache2\htdocs\youmightbe\outside.php* on line *12*
   
   *Warning*: feof(): supplied argument is not a valid stream resource in 
   *C:\Program Files\Apache Group\Apache2\htdocs\youmightbe\outside.php*on line 
   *12*
   

*Warning*: fclose(): supplied argument is not a valid stream resource
in *C:\Program
Files\Apache Group\Apache2\htdocs\youmightbe\outside.php* on line *22*
**

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux