I have a piece of code that opens a file into a text area for editing, but when I use fwrite() to save the text file and overwrite the old it palces escape characters every where therefore the file doesn't work anymore

How can I rectify this problem and stop fwrite() from inserting the escape char.

Here's my code.

$filename = "$page";
$fh = fopen($filename, 'w') or die('Could not open file!');
fwrite($fh, $body_text) or die( 'Could not write to file' );
fclose($fh);

ideas...I'm guessing maybe I should use something different then a w for permissions... I need to make changes to the file then overwrite it not add too it...

Thanks

    It places escape characters everywhere?

    Do you mean that
    "hello's to you"
    becomes
    "\h\e\l\l\o\'\s\ \t\o\ \y\o\u"
    or does it become
    "hello\'s to you"
    ?

    In the former, you appear to have a serious problem, and more information is needed.

    Otherwise, look into [man]stripslashes/man

      Write a Reply...