Hi!
I use a relatively simple code for adding text from forms to text files.
<?php $file = fopen('file.txt', 'a'); fputs($file, $message); fclose($file); ?>
But every ' and " it writes /' and /"... Is there any way getting around it?
fputs($file, strip_slashes($message));
And btw, it's a backslash, not a forward slash.
Diego
Just like the subject says.
<?php if ($viesti != '') { $uusirivi = ' ' . strip_tags($viesti); $tiedosto = fopen('story.txt', 'a'); fputs($tiedosto, strip_slashes($uusirivi)); <-here something goes wrong fclose($tiedosto); } ?>
Any ideas?
I did a search on "strip slashes" and it turned out, that the right command was "stripcslashes()".
By the way, it's not a glitch. The backslashes are added because (as is the default) you have magic_quotes_gpc turned on in your php.ini file. This option makes PHP escape all quotes in variables sent through GET, POST, or through a cookie.