How to add line breaks in the textarea

in PHP Code / 1 Comment

When we dealing with a text area in the PHP application ,

for Example in your application given that About me feild,

suppose some of the users may given that “This is about Anil’s blog”.

When we try to insert into database then we got the some errors.

To avoid that error and insert into database without any errors:

$text = addslashes($text);

// $text is contents of text area.

To add the line breaks at time of insert into database:

$test= "This

so insert as it is format then put below line of code when time of insert:

$text = nl2br($text);

Thank You.

With more than 8 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ...Contact : [email protected]

Discussion 1 Comment

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>