stupid question ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheColdWinterAir
Forum Newbie
Posts: 1
Joined: Wed Aug 24, 2005 3:42 pm

stupid question ...

Post by TheColdWinterAir »

I have a lyrical website that i'm having problems getting something to work correctly,

When i have lyrics submitted to the database, the line breaks are correctly entered into the database without me having to put <br> after each line. However when i try to display the $lyrics variable on the site it puts the lyrics (which should be in poetry form) into paragraph form

i.e:

If i submit something like -
Roses Are Red
Violets Are Blue

The display on the site becomes
Roses Are Red Violets are Blue

Any way to fix this?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

html does not use \n as a line break so you have to change any \n as a <br> but the best way would be as jcart said as that nl2br which basically does that changing \n to a <br> but it might be better if you just put all of the \n as a <br> in the database first off becuase it might just make everything a bit easier
Stewsburntmonkey
Forum Commoner
Posts: 44
Joined: Wed Aug 24, 2005 2:09 pm

Post by Stewsburntmonkey »

It would certainly be more efficient that way. :)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

tell us how you end up doing everything for the knowledge of the rest :D
Post Reply