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
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
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
Share on other sites

If only computing was invented by a man. We would have just one programming language, and one instruction execute() ant that would be all we need. Alas, it was Lady Ada Lovelace who invented it, and she made it all complicated, just like women do.

 

[/joke]

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.