stripslashes() for editor

stripslashes() for editor

mcflausemcflause Posts: 10Questions: 0Answers: 0
edited June 2012 in Editor
My server has magicquotes enabled (cannot disable it). I need to remove the slashes before inserting the value into the database. How would I do this? (How would I use stripslashes() with editor?)

It turns 5 1/2" into 5 1/2\"

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    There are a number of ways you could do this. Possibly the best option (other than turning magic quotes off - baring in mind that they are been completely removed in v5.4 :-) ) is to use this in your .htaccess file (assuming that you are using Apache):

    [code]
    php_flag magic_quotes_gpc off
    [/code]

    Otherwise you could use something like this at the very top of the file:

    [code]
    if (get_magic_quotes_gpc()) {
    function stripslashes_gpc(&$value)
    {
    $value = stripslashes($value);
    }
    array_walk_recursive($_GET, 'stripslashes_gpc');
    array_walk_recursive($_POST, 'stripslashes_gpc');
    array_walk_recursive($_COOKIE, 'stripslashes_gpc');
    array_walk_recursive($_REQUEST, 'stripslashes_gpc');
    }
    [/code]

    Regards,
    Allan
  • mcflausemcflause Posts: 10Questions: 0Answers: 0
    I ended up using the second option. Thanks for the expertise!
This discussion has been closed.