Jump to content

Trying to Eliminate magic_quotes


X51

Recommended Posts

So I am trying to find a good alternative to this code:

 

	function clean($str) {
	$str = @trim($str);
	if(get_magic_quotes_gpc()) {
		$str = stripslashes($str);
	}
	return mysql_real_escape_string($str);
}

 

I did a few searches here and just keep coming up with instances of its use rather than a solution as I was hoping for. I was also checking the php manual and found user comments on it, but am not sure what is best to use rather than the magic_quotes.

 

Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/
Share on other sites

Code like this is used if you're going to be moving your code to a server and you're unsure if magic_quotes will be on or not.  This is true for scripts you will sell or otherwise distribute, or sites you'll be placing on shared hosts.  If you know magic_quotes will be off, don't handle it in your code.

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.