aeroswat Posted February 1, 2010 Share Posted February 1, 2010 Does using a post in a form automatically append backslashes to strings that have single quotes? It seems like it is doing it in my code. I am sending it a string that looks like this AU','BR','ET and it is echoing back this when i type echo $_POST['variablename']; AU\',\'BR\',\'ET Quote Link to comment https://forums.phpfreaks.com/topic/190538-help-with-post/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 1, 2010 Share Posted February 1, 2010 Unfortunately, yes. The magic_quotes_gpc setting being ON will cause GET, POST, and COOKIE data to be 'magically' escaped, even if you don't want it to be. You either need to turn the magic_quotes_gpc setting off (it is settable on a PHP_INI_PERDIR basis) or if you cannot turn it off you must use the get_magic_quotes_gpc() function to test if it is on and then use stripslashes() on the data to remove the offending \ characters. You could unconditionally use stripslashes() on the data but that would prevent you from ever having a real \ as part of the data if magic_quotes_gpc is off. Quote Link to comment https://forums.phpfreaks.com/topic/190538-help-with-post/#findComment-1004979 Share on other sites More sharing options...
aeroswat Posted February 1, 2010 Author Share Posted February 1, 2010 Unfortunately, yes. The magic_quotes_gpc setting being ON will cause GET, POST, and COOKIE data to be 'magically' escaped, even if you don't want it to be. You either need to turn the magic_quotes_gpc setting off (it is settable on a PHP_INI_PERDIR basis) or if you cannot turn it off you must use the get_magic_quotes_gpc() function to test if it is on and then use stripslashes() on the data to remove the offending \ characters. You could unconditionally use stripslashes() on the data but that would prevent you from ever having a real \ as part of the data if magic_quotes_gpc is off. Ty. Just didn't know if POST was supposed to do that. I went ahead and added the stripslashes to the individual area that required it Quote Link to comment https://forums.phpfreaks.com/topic/190538-help-with-post/#findComment-1004981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.