Dat Posted October 9, 2007 Share Posted October 9, 2007 I'm new to this forum, but anyway. I have this variable with slashes using mysql_real_escape_string () I want to remove the slashes away from the variable without removing the \r\n ect. $title = mysql_real_escape_string( $_POST['title'] ); In the variable that is currently being inputed: Miki Koishikawa\\\'s ordinary life... Input in the database (as you may already know): Miki Koishikawa\'s ordinary life... As you can see what is left is the \'s I can't use stripslashes () because that would remove the \ from \r\n and that would leave me with rn. Help? ??? Quote Link to comment https://forums.phpfreaks.com/topic/72411-solved-remove-slashes-from-double-and-single-quotes/ Share on other sites More sharing options...
btherl Posted October 9, 2007 Share Posted October 9, 2007 It's very odd that you have \r and \n literally in your database strings. How did this happen? Also, there is no need to store the backslash in the database. It looks like you have 2 levels of escaping there when you only need 1. I suspect that what you need is this: $title = mysql_real_escape_string(stripslashes($_POST['title'])); Then your input will not have the extra backslashes in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/72411-solved-remove-slashes-from-double-and-single-quotes/#findComment-365199 Share on other sites More sharing options...
dingus Posted October 9, 2007 Share Posted October 9, 2007 well with out over complicating the process i have one suggestion that would work to keep /r/n and that would be a str_replace function first $tital = str_replace ("/r/n", "//r//n", $_POST['title']) $tital = stripslashes($tital); Quote Link to comment https://forums.phpfreaks.com/topic/72411-solved-remove-slashes-from-double-and-single-quotes/#findComment-365202 Share on other sites More sharing options...
Dat Posted October 9, 2007 Author Share Posted October 9, 2007 I got it... function escape_data ($data) { global $dbc; // Need the connection if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysql_real_escape_string(trim($data), $dbc); } Quote Link to comment https://forums.phpfreaks.com/topic/72411-solved-remove-slashes-from-double-and-single-quotes/#findComment-365729 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.