cs.punk Posted May 13, 2009 Share Posted May 13, 2009 Copying something from a form and putting it into a MySQL cell, data will be removed of any line breaks... so how will i go about to make em last?.. use javascript?... i want something like this see?... sorry but our net is down so im using my mobile.... if you notice its a bit 'ugly' lol Quote Link to comment https://forums.phpfreaks.com/topic/157984-how-to-get-linebreaks-from-a-form/ Share on other sites More sharing options...
AmandaF Posted May 13, 2009 Share Posted May 13, 2009 You can use preg_replace to escape the newline characters or replace them with HTML tags (<p> or <br>). Just keep in mind that different OSes represent newlines different ways, so the user's OS will affect how the linebreaks are encoded. (If I remember correctly, it's \n in Linux/Unix, \r in OSX and \n\r in Windows.) So you might want to replace all occurrences of \n\r with \n, and then replace all occurrences of \r with \n, and then replace the \n with \\n or <br> or whatever. Quote Link to comment https://forums.phpfreaks.com/topic/157984-how-to-get-linebreaks-from-a-form/#findComment-833373 Share on other sites More sharing options...
wildteen88 Posted May 13, 2009 Share Posted May 13, 2009 new lines are added to the database. Its actually your browser which does not display them. When displaying data from your database that has new lines. You should use nl2br to convert them into HTML line breaks (<br />). Quote Link to comment https://forums.phpfreaks.com/topic/157984-how-to-get-linebreaks-from-a-form/#findComment-833375 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.