kevinkorb Posted January 18, 2007 Share Posted January 18, 2007 When I post a string from a textbox, I then clean it for mysql...When I output the string to an update textarea, it actually comes out \r\n instead of the line breaks.i.e.$_POST['myTextArea'];$clean = mysqli_real_escape_string($_POST['myTextArea']);mysqli_query("INSERT INTO myTable (myVal) VALUES ('$clean');");When getting the data back outSay I entered in..test1test2test3my textbox populatestest1\r\ntest2\r\ntest3\r\nwhen I do a stripslashes on it it outputstest1rntest2rntest3rnHow do I get the database to recognize the breaks and not literal text? Or how do I get the data out as planned?Thanks. Link to comment https://forums.phpfreaks.com/topic/34818-line-breaks-rn-mysql/ Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 don't do stripslashes, use nl2br and then stripslashes. Link to comment https://forums.phpfreaks.com/topic/34818-line-breaks-rn-mysql/#findComment-164103 Share on other sites More sharing options...
kevinkorb Posted January 19, 2007 Author Share Posted January 19, 2007 I'm trying to output it back into a textarea to look exactly like it did originally... With the nl2br it will betest1<br>test2<br>test3 Link to comment https://forums.phpfreaks.com/topic/34818-line-breaks-rn-mysql/#findComment-164104 Share on other sites More sharing options...
wildteen88 Posted January 20, 2007 Share Posted January 20, 2007 mysqli_real_escape_string shouldn't effect it, as \r and \n are invisible characters. Somewhere in your script it is causing this. What happens when you run nl2br on the string does it convert the \r\n in to a HTML line break ([nobbc]<br />[/nobbc])? Link to comment https://forums.phpfreaks.com/topic/34818-line-breaks-rn-mysql/#findComment-165070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.