Page 1 of 1

why doesn't it works

Posted: Wed May 21, 2003 2:09 pm
by micknic
Hi,

Does anyone know what it doesn't works:

<?php
$fp=fopen("c:\\histo\\OOO\\hist.txt", "r");
echo $fp;
?>



Warning: fopen("c:\histo\OOO\hist.txt", "r") - No such file or directory in c:\program files\easyphp\www\maredsous\intranet\lecture.php on line 2

Posted: Wed May 21, 2003 2:31 pm
by liljester
have you checked file permissions on the file in question? also try something like this:

Code: Select all

<?php
$file_name = "c:\\histo\\OOO\\hist.txt";
$fp=fopen($file_name, "r"); 

echo $file_name ."<BR>\n";
echo $fp; 
?>
to verify that the string your passing the fopen() is indeed what you think it is.

chdir

Posted: Wed May 21, 2003 3:31 pm
by phpScott
You might have to change to the directory in which the file is located.

Code: Select all

chdir("c:\\histo\\OOO");

then

$fp=fopen("hist.txt", "r");
phpScott
?>

Posted: Wed May 21, 2003 7:37 pm
by volka
btw: $fp is the filedescriptor returned by fopen() not the content of the file.

Take a look at http://php.net/file and http://php.net/file_get_contents