X51 Posted January 17, 2012 Share Posted January 17, 2012 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 More sharing options...
scootstah Posted January 17, 2012 Share Posted January 17, 2012 What's wrong with that? Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308651 Share on other sites More sharing options...
Muddy_Funster Posted January 17, 2012 Share Posted January 17, 2012 if it's a big problem for you the "solution" is to turn it off in the php.ini file Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308656 Share on other sites More sharing options...
ManiacDan Posted January 17, 2012 Share Posted January 17, 2012 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 https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308664 Share on other sites More sharing options...
X51 Posted January 17, 2012 Author Share Posted January 17, 2012 I was under the impression that magic_quotes were being eliminated so I was searching for other ways to do the same thing. Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308698 Share on other sites More sharing options...
PFMaBiSmAd Posted January 17, 2012 Share Posted January 17, 2012 You can continue to use that exact same logic when magic_quotes are removed. get_magic_quotes_gpc() will still be present, but will always return a FALSE value. Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308699 Share on other sites More sharing options...
X51 Posted January 17, 2012 Author Share Posted January 17, 2012 I see, thanks for the responses Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308712 Share on other sites More sharing options...
ManiacDan Posted January 17, 2012 Share Posted January 17, 2012 That code you pasted will remove the effects of magic_quotes if it's enabled. The code is specifically designed to remove magic_quotes, so it, itself, was doing what you were trying to do by removing it. Link to comment https://forums.phpfreaks.com/topic/255241-trying-to-eliminate-magic_quotes/#findComment-1308732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.