Page 1 of 1

Problem with creating a file

Posted: Tue Jul 13, 2004 12:52 pm
by pickle
Hi All,

I'm having a little problem with creating a file and writing to it. I'm getting the error on this line:

Code: Select all

$file_handle = fopen("/path/to/the/file/to/create/$curr_date_$_POST[surname]_$_POST[first_name].txt",'w+');
The error I'm getting is;
PHP wrote: Warning: fopen(/path/to/the/file/to/create/1_2.txt) [function.fopen]: failed to create stream: No such file or directory in /path/to/file/doing/the/creation/file.inc on line 167
Line 167 is the code shown above.

I know the file name is correct, or at least valid, and I'm pretty sure about permissions, though this doesn't look like an error related to permissions.

I've tried using 'w','w+','a','wb' (not sure what wb is, though it was in the docs), but to no avail. Any ideas?

Posted: Tue Jul 13, 2004 12:55 pm
by Weirdan
Are you trying to create a file in non-existing directory?

Posted: Tue Jul 13, 2004 1:01 pm
by feyd
the b in wb is for binary.. just like wt is for text.

"/path/to/the/file/to/create/1_2.txt" differs from what should come from "/path/to/the/file/to/create/$curr_date_$_POST[surname]_$_POST[first_name].txt".. there should be atleast 2 underscores in the filename...

Posted: Tue Jul 13, 2004 1:05 pm
by pickle
Words cannot express how stupid I feel. Thanks.

~feyd - ya I know that's messed up. A separate issue though. Thanks.