Jump to content


Photo

Line Breaks In MySQL Withour <br> tag


  • Please log in to reply
2 replies to this topic

#1 $cripts

$cripts
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 21 March 2006 - 10:56 PM

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

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 21 March 2006 - 11:08 PM

Store it in MySQL exactly as you get it from the user. Then when you are displaying it, use something like:
echo nl2br(htmlspecialchars($row['text']));
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.

#3 $cripts

$cripts
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 21 March 2006 - 11:15 PM

[!--quoteo(post=357133:date=Mar 21 2006, 06:08 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 21 2006, 06:08 PM) View Post[/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:
echo nl2br(htmlspecialchars($row['text']));
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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users