whelpton Posted February 1, 2009 Share Posted February 1, 2009 I am currently trying to make an editable profile section using text files and updating form sections. The problem I am having is that the form does not recognise new lines properly. I allways have to enter <br> to create a new line. Is there anyway round this problem? Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/ Share on other sites More sharing options...
trq Posted February 1, 2009 Share Posted February 1, 2009 Use nl2br when displaying your data back from the database. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752013 Share on other sites More sharing options...
whelpton Posted February 1, 2009 Author Share Posted February 1, 2009 Thanks, but it isnt being inserted into a DB its being inserted into a basic text file and when submitted it looses all of its formatting, so there isnt any "/r"'s or anything in the text file. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752021 Share on other sites More sharing options...
trq Posted February 1, 2009 Share Posted February 1, 2009 Doesn't matter if you use a database or a text file. The /n newlines are invisable. You wouldn't use nl2br when you putting your data back into a text area for editing, but when you are displaying it on your web page. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752023 Share on other sites More sharing options...
whelpton Posted February 1, 2009 Author Share Posted February 1, 2009 well this is my page so far: http://www.alportstudios.co.uk/shared/profilecopy/ In the profile section, the text Default Profile test test test WOOOO Has been imputted from my form with multiple line breaks, and a <br> tag which has worked. Im using the nl2br function but it isnt working. When looking at my text file, the formatting is correct when viewed in notepad, but it isnt capturing any line breaks at all apart from the tag. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752027 Share on other sites More sharing options...
corbin Posted February 1, 2009 Share Posted February 1, 2009 To a web browser, a line break means nothing, so if you want something to have a line break, it MUST converted to <br> or <br />. So, to have the line breaks show up in that part, you would need to use nl2br. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752038 Share on other sites More sharing options...
whelpton Posted February 1, 2009 Author Share Posted February 1, 2009 Thanks for the replys everyone, I am using nl2br and I understand that line breaks dont mean anything to a web browser, the real problem is converting breaks into <Br> tags without having to type them into the form. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752041 Share on other sites More sharing options...
corbin Posted February 1, 2009 Share Posted February 1, 2009 That's exactly what nl2br does.... Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752046 Share on other sites More sharing options...
whelpton Posted February 1, 2009 Author Share Posted February 1, 2009 but its not... Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752066 Share on other sites More sharing options...
trq Posted February 1, 2009 Share Posted February 1, 2009 We need to see the relevent code then. Link to comment https://forums.phpfreaks.com/topic/143377-line-breaks-form-trouble/#findComment-752081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.