Page 1 of 1

Getting line breaks to work?

Posted: Wed Jun 25, 2003 7:30 am
by Gappa
Hey all, I got a piece of code going along, much to the help of people here such as volka hehe... but yeah, it access a database (shared with phpbb) grabs some text, (post_text) now (hopefully one of) my problem(s) is that line breaks arnt happening or return, what ever you would like to call them... do these need to be enable some how??

Posted: Wed Jun 25, 2003 7:32 am
by []InTeR[]
I'm not realy sure what you asking, but i think you need nl2br

Posted: Wed Jun 25, 2003 7:54 am
by Gappa
Hmm well im using phpbb, same forum as this and when you type into these textboxes and you press ENTER it doesnt place like <br>

but still when you view it has the line breaks...

Gah its hard to explain sorry... this nl2br , might be what im after but not sure

Posted: Wed Jun 25, 2003 8:12 am
by twigletmac
Definitely sounds like you need nl2br() - it adds HTML line breaks (<br />s) alongside new line characters (which are what are inserted when you press enter in a text field).

Mac

Posted: Wed Jun 25, 2003 8:31 am
by Gappa
Ahh ok, hmm reading the manual part on using nl2br didnt tell me alot about actually using it in my script, hmm forgive my newbness, but a lil help in how to if possible?

I want tp apply it to this section of my script:

Code: Select all

<?php echo $row['post_text']; ?>

Posted: Wed Jun 25, 2003 8:52 am
by twigletmac
Just use it on the variable like so:

Code: Select all

<?php echo nl2br($row['post_text']); ?>
Don't worry about being new to this, we all had to start somewhere.

Mac

Posted: Wed Jun 25, 2003 9:15 am
by Gappa
Cheers, mac, i think i kinda jumped the gun, i got 3 weeks of holidays now so i think i will try teach myself in a more structured way, rather than just doign this and that....

thanks again :)