SoireeExtreme Posted July 24, 2007 Share Posted July 24, 2007 Ok, I'm saving html and text from a text area to the database. Heres the code. The Text Area print "<center>Headline:<br><textarea name='headline' rows='1' cols='60'>$userstats3[headline]</textarea><br></center>"; Save to database if(isset($_POST['submit'])) { $headline=mysql_real_escape_string(str_replace("\r\n","<BR>",$_POST['headline'])); $SQL = "update d_users set headline='$headline' where username='$userstats3[username]'"; mysql_query($SQL) or die("could not register"); Now my problem is when I save it. \r\n doesn't turn into the < br > as it should. From what I know is that its stripping it? Why is that? Any help would be greatly appreciated. Thanks in advance. Oh I almost forgot to meantion. When I remove the \\ from the rn it will save it like I want to. But there is a problem that is created with that then. The problem with that is there are words with rn together in them and it will do the same thing to those words which I don't want to happen. Also to add, I get this problem when I try to hit enter to make a new line when saving the the information from the textfield. If anymore info is needed please let me know. Thanks again. Quote Link to comment Share on other sites More sharing options...
btherl Posted July 24, 2007 Share Posted July 24, 2007 Try printing out this: print urlencode($_POST['headline']); \r will show up as %0d, and \n will show up as %0a. Then check to see if it's what you expect. You might want to look at nl2br() as well. You can always strip out the \n and \r after using nl2br(). 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.