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

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.