How to remove \ before quotation marks in input form

Hi, when I post something on my site and use quotes in it, I get something like this

\ "

What do I need to do for my code to fix this?

+5
source share
3 answers

Probably the Magic Quotes that triggers this behavior. Try disabling them or deleting them with stripslashes.

+4
source

This is due to the PHP setting magic_quotes_gpc that you have to work with. You can use stripslashes to remove the slash, but then the code will not work if the magic_quotes_gpc parameter is turned off. Something like this will probably solve this for you:

<?php
$string = $_POST['msg'];
if(get_magic_quotes_gpc()) {
  $string = stripslashes($string);
}
?>

( magic_quotes_gpc, , , ):

<?php
if(get_magic_quotes_gpc()) {
  foreach(array('_POST', '_GET', '_COOKIE') as $gpc) {
    foreach($$gpc as $k => $v) {
      ${$gpc}[$k] = stripslashes($v);
    }
  }
}
?>
+2

You will need to use Stripslashes () to get it to output without them. The default is here.

http://au.php.net/manual/en/function.stripslashes.php

0
source

All Articles