NYCPHP Meetup

NYPHP.org

[nycphp-talk] phantom file writing errors

Tim Gales tgales at tgaconnect.com
Mon Jul 26 18:54:46 EDT 2004


Marc Antony Vose writes:

Can anyone tell my why I would get this error:
Warning: fwrite(): supplied argument is not a valid stream resource in 
Warning: fclose(): supplied argument is not a valid stream resource in

when the script is in fact opening and writing out 
the file just fine?

Are you %100 certain about the file 
being written to?

Hou did you assign the variable 
$output_h?

The code was:

// output the file
$output_h = fopen($output_path,"w");
fwrite($output_h,$output);
fclose($output_h);

If you assign the variable $output_path 
like thie:

$output_path = 'test.txt';

the code snippet will work.

You can use is_resource($output_h) to make 
certain the resource got created.

Perhaps you misspelled the variable name 
$output_path --
Try $Output_path = 'test.txt'; 
and compare the results.

(sorry if you are asking a different 
question -- i.e. how can the fwrite 
function work when it is not being 
passed a vaild (file handle) resource -- 
I don't see how that could work)

T. Gales & Associates
'Helping People Connect with Technology'

http://www.tgaconnect.com





More information about the talk mailing list