Page 1 of 1
Annoying backslashes
Posted: Fri Mar 10, 2006 7:46 am
by djwk
Hello,
Here's my code:
Code: Select all
<?php
$msg = $_POST['msg'];
$file = "display.txt";
$fp = fopen("$file", "w");
fwrite($fp, $msg);
fclose($fp);
?>
If I type a ' or a " into the 'msg' textbox on the previous form it prints it as \' or \"
How do I stop this happenening?
Posted: Fri Mar 10, 2006 7:51 am
by newmember
that easy

stripcslashes()
Posted: Fri Mar 10, 2006 7:57 am
by djwk
I did
and it still displays the backslash
Posted: Fri Mar 10, 2006 8:01 am
by newmember
can you show the piece of code where you strip slashes?
Posted: Fri Mar 10, 2006 8:02 am
by shiznatix
you gotta strip them out when outputting, when you write to the file for whatever reason it adds slashes automatically
Posted: Fri Mar 10, 2006 8:19 am
by djwk
nevermind, i forgot to put the '$msg =', working now, thanks for ur help
Posted: Fri Mar 10, 2006 10:04 am
by s.dot
try stripslashes() (not cslashes) dunno if it'd make a difference
but your quotes are being escaped most likely because you have magic quotes gpc enabled
so, either
ini_set("magic_quotes_gpc","Off");
or
$msg = stripslashes($_POST['msg']);
Posted: Fri Mar 10, 2006 10:06 am
by djwk
Don't you read any other post other than the first?
Quote from my last post:
working now
....
Posted: Fri Mar 10, 2006 1:25 pm
by s.dot
djwk wrote:Don't you read any other post other than the first?
Quote from my last post:
working now
....
obviously I did, given the data contained in my post.
i must've looked over your final post
word of advice, that attitude won't get you much help on the boards.