Jump to content

How do you stop the page from stretching?


Zoofu

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 |

______________________________________________________________|

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.