Page 1 of 1

File operations problem

Posted: Wed Jun 22, 2005 12:52 pm
by srirams
All,

I get the following message:
Warning: fread(): supplied argument is not a valid stream resource in C:\program files\Apache Group\Apache2\htdocs\filehandle2.php on line 4

Warning: fclose(): supplied argument is not a valid stream resource in C:\program files\Apache Group\Apache2\htdocs\filehandle2.php on line 5

The code is

<?
$myFile = "test.txt";
$fh = fopen($myfile, 'r');
$theData = fread($fh,3);
fclose($fh);
?>

I have verified that the file test.txt exists and has some text in that. But I don't know why the above error message is appearing.
Could someone else.

Posted: Wed Jun 22, 2005 1:10 pm
by timvw
I'm pretty sure fopen returns NULL instead of a "resource". Might want to check if you (the script) has enough rights.

Re: File operations problem

Posted: Thu Jun 23, 2005 9:50 am
by wwwapu
Remember case sensitivity of the variable names

Code: Select all

$myFile = "test.txt";// note F
$fh = fopen($myfile, 'r'); // note f
$theData = fread($fh,3);
fclose($fh);