Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Strip slashes based on magic_quotes settings

Here is a function that checks magic_quotes and then accordingly strips slashes in your text. It can be used to clean text before using mysql_real_escape string, if you can't disable magic_quotes. Or just clean text after taking it out of database:

<?php
function strip($val) 
{
    if (TRUE == function_exists('get_magic_quotes_gpc') && 
        get_magic_quotes_gpc() == 1)
    {
        $mqs = strtolower(ini_get('magic_quotes_sybase'));

        if (TRUE == empty($mqs) || 'off' == $mqs)
        {
            $val = stripslashes($val);
        }
        else
        {
            $val =  str_replace("''", "'", $val);
        }
    }
    return $val;
}
?>

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus