Jump to content

ini_set not seeming to work on gpc


Ninjakreborn

Recommended Posts

I wanted to always make those damn magic quote's off I did this in my config file,
ini_set("magic_quotes_gpc", 0);
that has been there, but I just noticed, it was running addslashes for some reason.  I didn't even use mysql real escape string but it was addingslashes to it anyway, and I am having to stripslashes, I was just wanting to remove those but it's not working
ini_set("magic_quotes_gpc", 0); that is what I used?
Link to comment
Share on other sites

You cannot use ini_set to turn off magic_quotes_gpc

magic_quotes_gpc can only be turned off in either of the following:
php.ini
.htaccess
httpd.conf

ini_set can only be used to change certain settings values in the php.ini. It cannot change every setting in the php.ini

You can only disable magic_quotes_runtime in your PHP scripta using set_magic_quotes_runtime(0). However magic_quotes_runtime is not the same as magic_quotes_gpc. magaic_quotes_gpc escapes quotes in GET/POST/Cookie data. magic_quotes_runtime escapes data from external sources such as databases, text files, functions etc.

If you cannot use .htaccess file then you'll need to test for magic_quotes_gpc and if its enabled you'll have to skip the part where you addslashes, or you could use stripslashes and then do whatever you do for example:
[code=php:0]function makeSafe($data)
{
    if(get_magic_quotes_gpc())
    {
        // magic_quotes_gpc is enabled
        $data = stripslashes($data);
    }

    // now you do whatever you do to escape quotes/make data safe

  return $data;
}[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.