Jump to content

[SOLVED] advice on r\n problem


shadiadiph

Recommended Posts

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 

Link to comment
Share on other sites

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: 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.