Jump to content

Line Breaks In MySQL Withour <br> tag


$cripts

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
Link to comment
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.
Link to comment
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
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.