Jump to content

[SOLVED] how do i keep line breaks with this code


ricmetal

Recommended Posts

Insert the code into the DB without trying to change line breaks.

 

When you subsequently retrieve it from the DB, and want to display it, use the nl2br() function

 

when i insert the data to the db without changing line breaks the db is populated with a <br>

 

when retreiving, the <br> stays and doesnt perform a line break, when using the nl2br() function

 

@mr shawn

i never get those chars to replace in the first place

@ricmetal

 

that method would only work after you had use htmlspecialchars() function. It is just to replace the special chars back to tags.

 

but after htmlspecialchars, the special chars are changed to tags...and the tags aren't rendered. i dont know why.

 

please help

 

okay, i got it.

it works fine with using nl2br after using the htmlspecialchars.

 

ps. i failed to see that i was fetching some data to insert to the db from innerHtml, so the br tag was appearing in the db on those data fields.

 

okay, i got it.

it works fine with using nl2br after using the htmlspecialchars.

 

ps. i failed to see that i was fetching some data to insert to the db from innerHtml, so the br tag was appearing in the db on those data fields.

 

 

becuase < is changed to < so you will see the tags

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.