Jump to content

Archived

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

$cripts

Line Breaks In MySQL Withour <br> tag

Recommended Posts

Ok so i have a forum i developed and right now im using bbcode as a way to have line breaks but how would i do it so when they go down a line it does it by itself.
So
I
Can
Do
This
without using bbcode and adding [br] with each one it just does it itself

Share this post


Link to post
Share on other sites
Store it in MySQL exactly as you get it from the user. Then when you are displaying it, use something like:
[code]echo nl2br(htmlspecialchars($row['text']));[/code]
That will replace line breaks with <br> and will also replace < with &lt; and > with &gt; so that their HTML shows up as HTML text instead of being rendered.

Share this post


Link to post
Share on other sites
[!--quoteo(post=357133:date=Mar 21 2006, 06:08 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 21 2006, 06:08 PM) [snapback]357133[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Store it in MySQL exactly as you get it from the user. Then when you are displaying it, use something like:
[code]echo nl2br(htmlspecialchars($row['text']));[/code]
That will replace line breaks with <br> and will also replace < with &lt; and > with &gt; so that their HTML shows up as HTML text instead of being rendered.
[/quote]

lol man.....simple stuff gets me so confusseld sometimes

Share this post


Link to post
Share on other sites

×

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.