PHP fopen returning null on files that work fine with include and get_file_contents

Posted by brad allred on Stack Overflow See other posts from Stack Overflow or by brad allred
Published on 2010-03-11T04:17:43Z Indexed on 2010/03/12 16:07 UTC
Read the original article Hit count: 399

Filed under:
|
|
|
|

Hi,

I have XAMPP installed on a windows 2000 server. everything is working great except the PHP fopen function. I can neither create nor open files with it. the strange thing is that i can include/require/file_get_contents/other file related functions; also fopen does not generate any errors or notices it just returns NULL.

I have gone as far as to grant full control of the file and all enclosing folders to everybody but i still get NULL instead of a file pointer.

I have tried this on php 5.2.9, 5.2.13, and 5.3.1 with the same effect. i have gone through the php.ini file looking for something that is breaking it; i have even tried deleting and using the basic ini file from a linux box where fopen is working and still nothing.

I know i have to restart apache after changing my ini and all that and have been (I have even restarted the server) so thats not it.

I am at this poing assuming it is an apache configuration issue somehow, tomorrow im going to run a test through php-cli to make sure.

I really don't want to bruise my head anymore over this can some apache/php wizard come to my aid?


Hi guys,

thanks for the responses. you are right is is not any config problem. the problem has to be with one of my dlls or one of my included files. I just tried the same code that isn't working in a new file without any include and i disabled my custom libraries and it worked.

for the record here is what I was doing that wasn't working:

$test_file = 'c:\\test.csv';//everybody has full control. is very large.
    if(file_exists($test_file) && is_readable($test_file)){
        $fp = fopen($test_file, 'r');
        echo var_export($fp, true);//outputs NULL. on my linux box this is a number.
        if($fp !== false){
            //do the work
            fread($fp, 10);//throws the error that $fp is not a valid file handle
        }
    }

something that i am including must be breaking fopen somehow. works as expected in new file with no includes.

© Stack Overflow or respective owner

Related posts about php

Related posts about fopen