php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21649 This this problem with fopen() function for windows
Submitted: 2003-01-15 02:03 UTC Modified: 2008-02-17 12:37 UTC
Votes:16
Avg. Score:4.4 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:3 (50.0%)
From: lipinski7722 at rogers dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.3.0 OS: win2000 server
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lipinski7722 at rogers dot com
New email:
PHP Version: OS:

 

 [2003-01-15 02:03 UTC] lipinski7722 at rogers dot com
$fp = fopen("C:\authenticate.txt","r",1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);

in include_path I have 

include_path c:\php4\pear;c:\ c:\php4\pear;c:\ 

That what I got

Warning: fopen(C:\authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 3

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 4

As You can see I have Apache2.
Since I'm more oracle guru than PHP I'd like to see
more consistent way You do bug reporting I will benefit
everbody.
Best Regards
W.J.Lipinski

Patches

JCfUZQsq (last revision 2020-05-14 13:24 UTC by sample at email dot tst)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-15 02:12 UTC] lipinski7722 at rogers dot com
I just want to say that I included double \\ in path
as well no luck
$fp = fopen("C:\\authenticate.txt","r",1);
 [2003-01-15 03:10 UTC] sniper@php.net
What is the exact include_path line in your php.ini?

 [2003-01-15 07:33 UTC] lipinski7722 at rogers dot com
Hi Sniper
; Windows: "\path1;\path2"
; include_path = ".;c:\php4\includes"
; include_path=".;c:\php4\pear"
  include_path="c:\php4\pear;c:\"

Please notice when I change path to ".;c:\php4\pear;c:\
Pear DB is complaining that cannot find what needed.
Onother story is that when You comment these line 
So You shoudn't see any lines.Isn't that strange

.;c:\php4\pear this is being shown  from <?php phpinfo();?>   
How include_path could be hardcoded????????

Best Regards
W.J.Lipinski
 [2003-01-15 08:36 UTC] lipinski7722 at rogers dot com
Hi 

I just change a line in php.ini
 include_path="c:\php4\pear;c:"

when I run after I restarted Apache 2 
<?php phpinfo();?>   

it shows
include_path c:\php4\pear;c: c:\php4\pear;c: 

Warning: fopen(C:\authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 3

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 4

Same error ???

Best Regards
W.J.Lipinski
 [2003-01-15 09:30 UTC] sniper@php.net
Please use the 'Edit Submission' page when you edit your own bug reports.

And does your example work with the ".;c:\php4\pear;c:\"
as include_path ? And what error does the PEAR Db give then?

 [2003-01-15 10:58 UTC] lipinski7722 at rogers dot com
Hi Sniper
As You wish :))
This is what I got when I change a include_path as
You suggested
include_path .c:\php4\pear;c:\ .c:\php4\pear;c:\ 
look at 
1.source 
<?php

$fp = fopen("C:\\authenticate.txt","r",1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);
....

?>

2.errors
a) fopen()
Warning: fopen(C:\authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 3

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 4

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

b) Pear db

Warning: main(DB.php) [function.main]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\login_db.php on line 2

Fatal error: main() [function.main]: Failed opening required 'DB.php' (include_path='.c:\php4\pear;c:\') in C:\Program Files\Apache Group\Apache2\htdocs\login_db.php on line 2




be more systematic :))  :))


I say changing the path in php.ini doesn't do the trick

I change it back to 
include_path="c:\php4\pear;c:\php4\php-4.3.0-Win32"
and put my authenticate.txt
afert kicking Apache I got 
from phpinfo()

include_path c:\php4\pear;c:\php4\php-4.3.0-Win32 c:\php4\pear;c:\php4\php-4.3.0-Win32 

read this portion and I need an anser please no more 
guess

$fp = fopen("C:\\php4\\php-4.3.0-Win32\\authenticate.txt","r",1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);



Now I got Pear DB working and same error with fopen()
this is a print out 

Warning: fopen(C:\php4\php-4.3.0-Win32\authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 3

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 4

Warning: fclose(): supplied argument 

I hope this will help You
Best Regards
W.J.Lipinski
 [2003-01-15 14:29 UTC] sniper@php.net
You're using the 3rd param for fopen(), which says to look in the include path for the file, but you're still using the absolute path to it..what if you change it to plain 'authenticate.txt' ??

 [2003-01-15 15:02 UTC] msopacua at idg dot nl
With the following script, I can't reproduce it on a win2k apache-1.3 system, with yesterday's stable snapshot:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// notice the space in the include_path where a semicolon should be
// also with a solid path no error
ini_set('include_path', '.;d:\php4\pear c:\\');
echo ini_get('include_path'), '<br />';
// also with 'foo.txt', it works, when include_path is valid
$fp = fopen('c:\foo.txt', 'r', 1);
var_dump($fp);
if($fp)
        fclose($fp);
?>
 [2003-01-15 19:14 UTC] lipinski7722 at rogers dot com
Hi
Sorry Gents but nothing same error 

this is my include_path

1 ; Windows: "\path1;\path2"
2 ; include_path = ".;c:\php4\includes"
3  include_path=".;c:\php4\pear"
4 ; include_path="c:\php4\pear;c:\php4\php-4.3.0-Win32"

Please notice with this path Pear Db doesn't work
and complaining about files it has to open
When I uncommented line 4  pear Db that I installed
in c:\php4\pear works fine 
With all line commented 
phpinfo() shows me .;C:\php4\pear and Pear Db also
works OK
I tried all scenerio as
1. removing absolte path as Sniper suggested 
2. puting this code

ini_set('include_path', '.;c:\php4\pear c:\\');
echo ini_get('include_path'), '<br />';
$fp = fopen('authenticate.txt','r',1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);

That what I got it


.;c:\php4\pear c:\

Warning: fopen(authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 6

Warning: fread(): supplied argument is not a valid stream resource in C:\Program Files\Apache Group\Apache2\htdocs\authfile.php on line 7

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

Hope this will help You.I'm tried maybe going back to 
apache 1.3 isn't but suggestion and instaling latest
snapshot .Do I need win-
 [2003-01-15 19:17 UTC] lipinski7722 at rogers dot com
Do I need a wininstaller to install snapshot if so
How to do it ?
Is ther Apache 1.3 win-32 with SSL ?
Honestly to God I have less problems with Oracle 9.2.0.2
on my suse linux than that

Best Regards
W.J.Lipinski
 [2003-01-15 20:53 UTC] lipinski7722 at rogers dot com
Hi
I just switch to Apache 1.3 old one from 2.43
this is what I got as well
when I try

ini_set('include_path', '.;c:\php4\pear c:\\');
echo ini_get('include_path'), '<br />';
$fp = fopen('C:\php4\pear\authenticate.txt','r',1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);


.;c:\php4\pear c:\

Warning: fopen(C:\php4\pear\authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in c:\program files\apache group\apache\htdocs\authfile.php on line 4

Warning: fread(): supplied argument is not a valid stream resource in c:\program files\apache group\apache\htdocs\authfile.php on line 5

Warning: fclose(): supplied argument is not a valid stream resource in c:\program files\apache group\apache\htdocs\authfile.php on line 6

Well I this point I assume that this is not apache 
proble just binary windows dist 4.3 php is with
bugs .How I can install latest snapshot ,please I need
an anser not just maybe ,babe   :))  :))
or anybody out there has some simmilar story

Best Regards
W.J.Lipinski
 [2003-01-16 10:44 UTC] lipinski7722 at rogers dot com
Hi
So anybody have idea what to do with fopen(windows env)
or should I go back to Unix which snapshots are more
stable

Best Regards
W.J.Lipinski
 [2003-01-16 13:25 UTC] cg at gordimer dot net
Your include_path is wrong:

include_path c:\php4\pear;c:\ c:\php4\pear;c:\
should read
include_path="c:\php4\pear;c:\"

an then you should fopen "c:\authenticate.txt" like this:
$fp= fopen("autenticate.txt","r",1);
because c:\ is already in your include path and you use 1 as your 3rd parameter.

Christoph

Christoph
 [2003-01-16 14:33 UTC] lipinski7722 at rogers dot com
Hi 

I just try your solution.It doesn't work.
This is my path from <?php phpinfo();?>       

include_path c:\php4\pear;c:\ c:\php4\pear;c:\ 
Could You SEE IT!!!!!!!!!!!!!

This is a code I'm tring to run 
<?php
ini_set('include_path', 'c:\php4\pear;c:\\');
echo ini_get('include_path'), '<br />';

if(!$fp = fopen("authenticate.txt","r",1))
{ die("<P>could not open password file"); }
//$fp = fopen('C:\php4\pear\authenticate.txt','r',1);
$auth_file = fread ($fp, filesize($fp));
fclose($fp);

This is an error I'm getting

c:\php4\pear;c:\

Warning: fopen(authenticate.txt) [function.fopen]: failed to create stream: No such file or directory in c:\program files\apache group\apache\htdocs\authfile.php on line 5

could not open password file

Best Regards
W.J.Lipinski
 [2003-01-17 21:15 UTC] sniper@php.net
Are you sure the webserver user has rights to access that path even?

 [2003-01-18 11:52 UTC] lipinski7722 at rogers dot com
User is administrator this is on localhost
where PHP4 is configured as Apache 1.3 module
What else I have to do in hppdcon for apache ?????

Best Regards
W.J.Lipinski
 [2003-02-19 19:25 UTC] sniper@php.net
Using this script:

<?php
error_reporting(E_ALL);
ini_set('include_path','.;c:\\');
$fp=fopen('autoexec.bat','r', 1);
echo ini_get('include_path');
?>

I can't reproduce this (with PHP 4.3.2-dev) under Windows 2000. Please try it out.

 [2003-02-25 02:05 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2007-06-08 08:00 UTC] manny dot ovena at dev dot com
In order to change the include_path in pear you must reinstall pear after you have made the changes to the php.ini file.  Install PHP, change PHP.ini, and then use go-pear.bat.
 [2020-05-14 13:24 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: JCfUZQsq
Revision:   1589462658
URL:        https://bugs.php.net/patch-display.php?bug=21649&patch=JCfUZQsq&revision=1589462658
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC