jasonc Posted September 19, 2010 Share Posted September 19, 2010 Simple question about slashes. If a user uses slashes in their text will all of them be removed using 'stripslashes' function or only the ones that have the ' to the right of the slashes. ? sorry posted before its time..... peoples names like... o'grady o'murphy shows on the screen as o\'grady and o\'murphy Quote Link to comment https://forums.phpfreaks.com/topic/213832-will-stripslashes-remove-user-added-slashes/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 19, 2010 Share Posted September 19, 2010 Yes it will remove user entered \ characters. You should only use stripslashes on get/post/cookie data IF magic_quotes_gpc is ON. There is a function to test the magic_quotes_gpc setting - get_magic_quotes_gpc Quote Link to comment https://forums.phpfreaks.com/topic/213832-will-stripslashes-remove-user-added-slashes/#findComment-1112888 Share on other sites More sharing options...
jasonc Posted September 19, 2010 Author Share Posted September 19, 2010 ok this is what happend, the data is inputed in the form and then added to the database, mysql, using mysql_real_escape_string or addslashes not sure... function db_input($string, $link = 'db_link') { global $$link; if (function_exists('mysql_real_escape_string')) { return mysql_real_escape_string($string, $$link); } return addslashes($string); } later on when my admin replies to posts it is showing their names with \ in the name that have the hyphens ' in them how do i print and add to a string their names but not remove the \ or / added by the user in the other text areas of the form they fill out. there are no \ / in the database just the correct names, o'grady, o'murphy. why does this \ get added when the data is grabbed from mysql ? Quote Link to comment https://forums.phpfreaks.com/topic/213832-will-stripslashes-remove-user-added-slashes/#findComment-1112895 Share on other sites More sharing options...
PFMaBiSmAd Posted September 19, 2010 Share Posted September 19, 2010 why does this \ get added when the data is grabbed from mysql ? That's a different php problem. magic_quotes_runtime is causing that. You can and should turn off magic_quotes_runtime in your code. Quote Link to comment https://forums.phpfreaks.com/topic/213832-will-stripslashes-remove-user-added-slashes/#findComment-1112900 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.