Reputation: 2692
For example
I use
$content = nl2br($_POST['content']);
and when I type in something like this in my form
"I'll be going to the office today"
It'll return
"I\'ll be going to the office today"
Is there a way I can remove the \'s? or am I using the nl2br function wrong?
Upvotes: 1
Views: 85
Reputation: 3224
I'm guessing you're getting information via a POST or GET; try something like this:
<?php
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
?>
More information on the PHP manual
Upvotes: 0
Reputation: 163622
nl2br()
does no such thing! You have magic quotes on. Turn them off.
Upvotes: 4