From: "Cameron Badgley" <[EMAIL PROTECTED]>
> Hey, I'm trying to write a script which deletes a String from a file. The
> String that the user wants deleted is provided from a form and the file is
> named to2do.txt. I have a hidden variable called "deleting" that lets me
> know when the string has been submitted.
>
> I have written the following code but receive the error:
> Warning: fclose(): supplied argument is not a valid File-Handle resource
in
> /u3/7/cirop27/public_html/todo/to2doDEL.php on line 63
[snip]
> $mfile = fopen("to2do.txt",'r+');
This opens the file and makes $mfile a file handle, but it does not read it.
>
> //delete the string
> $mfile = str_replace($msg, "", $mfile);
You're overwriting the file handle here by using the same variable.
> /*** error occurs here ***/
> fclose($mfile);
You also need to write the new data to the file...
fread(), fwrite(), etc...
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php