Ninjakreborn Posted November 1, 2006 Share Posted November 1, 2006 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 workingini_set("magic_quotes_gpc", 0); that is what I used? Link to comment https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/ Share on other sites More sharing options...
Daniel0 Posted November 1, 2006 Share Posted November 1, 2006 Try to put this in your .htaccess file: [code]php_value magic_quotes_gpc off[/code] Link to comment https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/#findComment-117946 Share on other sites More sharing options...
Ninjakreborn Posted November 1, 2006 Author Share Posted November 1, 2006 I need something I can do from php specifically, because some places I don't have htaccess capabilities. Link to comment https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/#findComment-117955 Share on other sites More sharing options...
Daniel0 Posted November 1, 2006 Share Posted November 1, 2006 I don't think you can do that inside PHP, but you can do this: [code]<?phpif(get_magic_quotes_gpc() == true){ foreach(array("_POST","_GET","_COOKIE","_SESSION","_REQUEST") as $var) { $GLOBALS[$var] = array_map("stripslashes",$GLOBALS[$var]); }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/#findComment-117999 Share on other sites More sharing options...
wildteen88 Posted November 1, 2006 Share Posted November 1, 2006 You cannot use ini_set to turn off magic_quotes_gpcmagic_quotes_gpc can only be turned off in either of the following:php.ini.htaccesshttpd.confini_set can only be used to change certain settings values in the php.ini. It cannot change every setting in the php.iniYou 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 https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/#findComment-118004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.