note 39341 added to function.fwrite
| From: | bilkan at hotmail dot com | Date: | Sun, 25 Jan 2004 14:40:21 +0000 |
| Subject: | note 39341 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64144@lists.php.net to get a copy of this message | ||
I wrote the following code:
$input = "";
if(isset( $_POST['text_input']))
$input = $_POST['text_input'];
$low_input = strtolower($input);
$stringArray = explode(" ",$low_input);
$FileToWrite = 'c:\\inetpub\\wwwroot\\movies\\test.txt';
function fileWrite($str_array,$file)
{
fopen($file,'wb');
fwrite($file, "[");
for($i = 0; $i < count($str_array); $i++)
{
fwrite($file, "$str_array[$i],");
}
fwrite($file, "]");
fclose($file);
}
fileWrite($stringArray,$FileToWrite);
The progam creates the file "test.txt" but i have the following errors in the page:
Warning: fwrite(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\movies\b.php on line 14
Warning: fwrite(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\movies\b.php on line 17
Warning: fwrite(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\movies\b.php on line 19
Warning: fclose(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\movies\b.php on line 20
Any idea why?
thanks...
----
Manual Page -- http://www.php.net/manual/en/function.fwrite.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39341
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39341&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39341&report=yes
Search -- http://master.php.net/manage/user-notes.php