Zoofu Posted August 20, 2009 Share Posted August 20, 2009 I need to set it up so that the post messages don't stretch the screen, and that when I press the return key, it shows up in the post too, because when I post paragraphs, it just puts it all into 1 line and stretches the screen... http://zoofutest.hostzi.com/index.php?act=topic&id=21 Quote Link to comment Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 It's really irritating, why won't it come out like I entered it out? Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2009 Share Posted August 20, 2009 Where's your code? Are you saying that the text entered contains spaces and line breaks? If not, then your only resolution is to process any text and dynamically break it when there are "words" which are excessively long. Otherwise, there is no way to "break" it across lines. however, if the entered text does contain spaces and line breaks, something is removing it. Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 20, 2009 Share Posted August 20, 2009 OK, you need to use nl2br() on your text when echo'ing it to the page. When HTML code is rendered the browser does not interpret a new line character. But, your data is saved with the line breaks. So, just run it through nl2br() and it will convert new line characters into BR tags. Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted August 20, 2009 Share Posted August 20, 2009 I had that problem myself about a week ago. the nl2br function will make the structure from your post the same when you output it back onto the page. in addition, to prevent uses from being able to type aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa and exceeding the width of the textarea i used a custom function i came accross this site the other day, I use it myself and should work great for you too. <?php //taken from http://www.codingforums.com/archive/index.php/t-168890.html //just include this function at the top of the page or another file function wraptext($str, $limit) { $break = "<br>"; $limit = ( int ) $limit; return ($limit > 0 ? preg_replace('/(\S{' . ( $limit + 1 ) . ',})/e', 'wordwrap( \'\1\', ' . $limit . ', \'' . $break . '\', TRUE )', $str ) : $str); } $string = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; // and call upon it before you insert your post data into the database $finalcomment = wraptext($newcomment,50); //this function will seperate lengthy sets of characters ?> i hope this helps believe me it took me so long to find a solution for that problem HoTDaWg Quote Link to comment Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 The code is branched off from many different files. When I enter it out: (let's pretend this is the edge) ___________________________ | Hello, my name is billie, I like | pineapples and curry. | | Oh, and I like pizza. :3 | ___________________________| It comes out like: ______________________________________________________________ | Hello, my name is billie, I like pineapples and curry. Oh, and I like pizza. :3 | ______________________________________________________________| Quote Link to comment Share on other sites More sharing options...
Zoofu Posted August 20, 2009 Author Share Posted August 20, 2009 Okay, the linebreak thing worked, but it's still stretching when someone does it all on 1 line. Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted August 20, 2009 Share Posted August 20, 2009 Use function wordwrap(). Quote Link to comment Share on other sites More sharing options...
Prismatic Posted August 20, 2009 Share Posted August 20, 2009 Your web account seems to have been disabled... 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.