why doesn't it works

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

why doesn't it works

Post 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
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post 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.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

chdir

Post 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
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply