shadiadiph Posted May 9, 2009 Share Posted May 9, 2009 my problem is this if the user submits their message it goes back to the message and displays the message again however when the message displays on the error it is messed up it is just text ful of r\n\r\n how can I fix this for example hello\r\n\r\nwebmaster\r\n08-05-2009\r\nYou username and password for website.com\r\n\r\nHTML message \r\n \r\nDear Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 Do you want to get rid of them, or put some <br /> in place? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 nl2br? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 9, 2009 Author Share Posted May 9, 2009 i already tried nl2br did nothing made no differnce to it the text is being displayed in a <textarea> yes I want to tyun them back into linebreaks Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 you mean back into breaks? \n is a linebreak (that's not what you want) Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 Can you show your code? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 9, 2009 Author Share Posted May 9, 2009 when i first send it for displaying in the textarea i strip all the css and html tags first or it just displays as html in the text area but this is how i first get it to display $newmessage = preg_replace("'<style[^>]*>.*</style>'siU",'',$newmessage); $newmessage = strip_tags($newmessage); $newmessage = str_replace("\n\n\n", "", $newmessage); $newmessage = "\n\n\n".$touser."\n".$daterec."\n".$subject."\n".$newmessage."\n"; it is then returned as a $_POST and when it goes back into the message it displays like this before on first display webmaster 08-05-2009 You username and password for website.com HTML message Dear $user, You have successfully signed up website.com Your username and password are as below and both are case sensitive. Username: second display which i want it to go back to like the first display \r\nwebmaster\r\n08-05-2009\r\nYou username and password for websitecom\r\n\r\nHTML message \r\n \r\nDear $user,\r\n \r\nYou have successfully signed up at website.com\r\nYour username and password are as below and both are case sensitive.\r\n \r\nUsername: Quote Link to comment Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 Id nl2br() isn't working try using this; $replace = array("\r\n","\r","\n"); $newmessage = str_replace($replace, "", $newmessage); Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 9, 2009 Author Share Posted May 9, 2009 mm doesn't work still displays the same Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 9, 2009 Author Share Posted May 9, 2009 don't know if its relevant or not but when i post it i do this to it first $newmessage = $_POST["newmessage"]; $newmessage = stripslashes($newmessage); $newmessage = mysql_real_escape_string($newmessage); odd don't know why str_replace doesn't work i just tried it to replace just n and it worked but \n doesn't or \r or \r\n Quote Link to comment Share on other sites More sharing options...
gevans Posted May 10, 2009 Share Posted May 10, 2009 $newmessage = mysql_real_escape_string($newmessage); take that line out and it should be fine no need for mysql_real_escape_string() here Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted May 10, 2009 Author Share Posted May 10, 2009 yep thanks removing mysql_real_escape_string worked mysql_real_escape_string must lock a string or str_replace would work right used this as stripping \r\n removed all the breaks but then had to use strip_tags to get rid of the <br /> tags when it displayed $newmessage = nl2br($newmessage); $newmessage = strip_tags($newmessage); thanks for the help Quote Link to comment 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.