Jump to content

magic quotes


freelance84

Recommended Posts

This may be another really simple one...

 

I've been reading a lot about the magic quotes and that they are now deprecated. To get more control over sanitization of user input...etc I am using my own security functions.

 

I've also read that I should be turning them off.

 

I've read the section about disabling magic quotes but i'm not much wiser after reading, especially as some people on the manual page are saying contradictory things.

 

What do people recommend for the simplest and safest was to disable all magic quotes and there effects?

 

I am right in assuming that these magic quotes are a built feature to php and therefore this is why i have to turn them off?

Link to comment
https://forums.phpfreaks.com/topic/202669-magic-quotes/
Share on other sites

If your host will not let you disable magic quotes you will need to reverse it's effect. Usually it's done like this:

 

if(get_magic_quotes_gpc()) {
  //apply stripslashes() to POST/GET/COOKIE variables.
}

 

After that you should apply proper escaping functions (like mysql_real_escape_string) to any variables that go into your database queries.

Link to comment
https://forums.phpfreaks.com/topic/202669-magic-quotes/#findComment-1062316
Share on other sites

Sorry i'm confused, if magic quotes are on, what will this do?

if(get_magic_quotes_gpc()) 
         {
             //apply stripslashes() to POST/GET/COOKIE variables.
         }

 

Also, with regards to using the mysql_real_escape, I have been using this so far but am now considering using/ creating my own function:

One "entering" function which replaces any "unusual characters" with specified combinations of other characters for input.

One "taking" function which replaces the said combination back with the original characters.

This would mean I could use just two "santizing" functions for everything, and it could also be used on pages where no DB connection is needed.

Do you have any thoughts on this?

Link to comment
https://forums.phpfreaks.com/topic/202669-magic-quotes/#findComment-1062320
Share on other sites

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.