Panjabel Posted July 17, 2007 Share Posted July 17, 2007 I have a textarea but when i press enter it doesn't make a new line before adding to database i want, when i press enter to make a new line in text, lke "<br>" any advice ? thanks Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/ Share on other sites More sharing options...
lur Posted July 17, 2007 Share Posted July 17, 2007 http://php.net/nl2br Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300156 Share on other sites More sharing options...
Panjabel Posted July 17, 2007 Author Share Posted July 17, 2007 <?php $comment = $_POST['textarea_comment']; $comment = nl2br($comment); print $comment; ?> it doesn't make a new line when i press enter in textarea why ? Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300158 Share on other sites More sharing options...
Panjabel Posted July 17, 2007 Author Share Posted July 17, 2007 up Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300164 Share on other sites More sharing options...
Panjabel Posted July 17, 2007 Author Share Posted July 17, 2007 it works but it doesn't insert n mysql the new line, i mean it doesn't add "<br>" Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300167 Share on other sites More sharing options...
Daniel0 Posted July 17, 2007 Share Posted July 17, 2007 It DOES make a new line ( \n ), but not an HTML line break ( <br /> ). Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300172 Share on other sites More sharing options...
Panjabel Posted July 17, 2007 Author Share Posted July 17, 2007 confused with your code ??? Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300182 Share on other sites More sharing options...
GingerRobot Posted July 17, 2007 Share Posted July 17, 2007 A newline character is not the same as an HTML line break. Whenever you OUTPUT your data that you have stored, you'll need the nl2br() function. You dont use it before you enter the data into the database. Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300183 Share on other sites More sharing options...
Panjabel Posted July 17, 2007 Author Share Posted July 17, 2007 $comment = nl2br($comment); echo "insert into site_database.comentarii set `comment`='$comment'"; it doesn't print the new lines why ? Link to comment https://forums.phpfreaks.com/topic/60335-on-enter-in-textarea/#findComment-300185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.