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


Code below:

if($_POST['deleting']=='true'){

       //grab info from post array
       $msg = $_POST['deleteThis'];

//when the string was written to the file, this replace occured. it is repeated here
//for consistency
$msg = str_replace( "\n" , "<br>", $msg);


       //open msg file for read/write
       $mfile = fopen("to2do.txt",'r+');

       //delete the string
       $mfile = str_replace($msg, "", $mfile);

       /*** error occurs here ***/
       fclose($mfile);

}

to2do.txt is a valid file, as I was able to write to it and can view its contents.
Can anyone tell me if I am going about this the wrong way? Thanks for any help.


_________________________________________________________________
Groove on the latest from the hot new rock groups! Get downloads, videos, and more here. http://special.msn.com/entertainment/wiredformusic.armx


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to