Jump to content

Question regarding to addslashes().


bbmak

Recommended Posts

There is nothing automatic about slashes in php other than the magic_quotes_gpc which has been deprecated for a long time.  Furthermore, the mysql api is deprecated for mysqli and when using that api you should use named parameters which means you don't need to escape characters.  Last but not least, even if you are not using mysqli (or pdo which is an alternative with similar advantages) you should be using mysql_real_escape_string rather than addslashes.

You need to make sure you disable magic_quotes_gpc.

 

You cannot disable it at runtime, you can only strip the slashes that it applies, so if you have server access, then disable it.  This function has been depreciated in PHP5.3 and removed in PHP5.4.

 

runtime fix *FROM MANUAL


<?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);
}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.