Re: fgets fails after fopen succeeds

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

 



Printing $fh printed a 1.

My original file mode was just "r", I changed to "r+" to see if I'd get 
permissions problems. The file handle seems to be fine. fgets just doesn't 
like it.

The 0 && !feof() was a "commenting out" of the for loop to prevent the fgets 
from running so that I so print the $fh.

This is an adaptation of the following code, which works fine on another 
Windows 2000/Apache setup. Irony is, the original code doesn't work when 
ported. I think I'm missing something in setup or permissions.

<?
$page=$_GET['page'];
print 'new_pages/'.$page.'.txt';
$fh = fopen('./new_pages/'.$page.'.txt', 'rt'); 
?>
<ul>
<?
for ($line = fgets($fh); ! feof($fh); $line = fgets($fh)) {
$line = trim($line);
if(strlen($line) > 0) {
print '<li>' . $line ."</li>\n";
}
}
?>
</ul>
<?
fclose($fh);
?>

[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