Oziam Posted September 22, 2010 Share Posted September 22, 2010 Hi guys, I have come across a problem when working with session data, I have been storing data from a textarea in a session, but the problem is when I retrieve the data and display it back in a textarea or to mysql it saves the carriage returns and line breaks as \r\n not converting it to actual line breaks. e.g saving the following from a text area; Line 1 Line 2 Line 3 will actually show as: Line 1 \r\nLine 2 \r\nLine3 How do I get it to show properly as intended? I have tried str_replace('\r\n', '\n'); with double and single quotes any helpful suggestions would be much appreciated. Thanks.. Quote Link to comment Share on other sites More sharing options...
btherl Posted September 22, 2010 Share Posted September 22, 2010 Please post your code. I'll need to see everything related to getting the data from the form and storing it in the session, and everything from where the data is fetched from the session to where it is put into the HTML again. BTW "\n" is a linefeed, '\n' is a backslash followed by the letter n. Quote Link to comment Share on other sites More sharing options...
Oziam Posted September 22, 2010 Author Share Posted September 22, 2010 Yeah I figured it out. It was the textarea wrap attribute, I had it set to virtual which reads data as a string but I changed it to physical and now it saves the data correctly as intended. Sorry a HTML gotcha nothing to do with PHP. 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.