shadiadiph Posted March 19, 2009 Share Posted March 19, 2009 I am inserting a message to a database but at the same time sending it by email. the test message i am using is . line's one's line's two's problem i have is i am using mysql_real_escape_string($message) to insert it to the database. then when i print $message it says line\'s one\'s\r\n\r\nline\'s two\'s then if i use $message= stripslashes($message) then $message= nl2br($message) it returns 'sline's one'srnrnline's two's it doesn't break the line and prints rnrn??? Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/ Share on other sites More sharing options...
samshel Posted March 19, 2009 Share Posted March 19, 2009 do nl2br first then stripslashes..try it Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/#findComment-788155 Share on other sites More sharing options...
DarkWater Posted March 19, 2009 Share Posted March 19, 2009 You shouldn't be seeing '\r\n' in plain text like that. You put it into the database incorrectly, I think. Can I see your code for inserting it? Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/#findComment-788162 Share on other sites More sharing options...
shadiadiph Posted March 19, 2009 Author Share Posted March 19, 2009 samshel that kind of works it breaks the lines by doing that but still has the rnrn. darkwater the problem is not inserting it to the datbase it is inserting to the database fine and when i call it it looks fine the problem is in the email that is sent this is where rn is appering before i wasn't using mysql_escape_string and it was working fine but i am told that you have to use it Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/#findComment-788170 Share on other sites More sharing options...
shadiadiph Posted March 19, 2009 Author Share Posted March 19, 2009 it is mysql_real_escape_string that seems to be adding rnrn is there a function similar to striplashes to remove the rn that anyone knows about Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/#findComment-788171 Share on other sites More sharing options...
shadiadiph Posted March 19, 2009 Author Share Posted March 19, 2009 ok guys thatks for the input i solved just had to change the order a bit. $message = stripslashes($_POST["message"]); $message2 = ($message); $message = mysql_real_escape_string($message); then insert $message to the database then $message2 = nl2br($message2); before insering $message2 into the email Quote Link to comment https://forums.phpfreaks.com/topic/150071-solved-mysql_real_escape_string-and-nl2br-problem/#findComment-788176 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.