4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 php sending text to/from sql
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
craig
Junior WebHelper
Junior WebHelper


Joined: 09 Jul 2002
Posts: 3

PostPosted: Tue Jul 09, 2002 2:31 am (15 years, 5 months ago) Reply with QuoteBack to Top

hi, i scanned the boards but couldnt find an answer to this.

i have my php connected to a sql db to retrieve items of text.
in my database i have text items that are nicely spaced out with returns for new lines etc.
when i retrieve this using my php script it prints out as a long string (because html doesnt recognise returns).

is there a function, or a script, that i can run on my text to replace the returns with <br> or whatever?
Either when inputting the text (using a php form) or retrieving the text from the database, or even both if needed.

it's probably really simple, i tried looking through the script for a BB but couldnt find it. I also have a problem with ' . Are there any other characters i need to be wary of?

Thanks in advance.
OfflineView User's ProfileFind all posts by craigSend Personal Message
jayant
Team Member



Joined: 07 Jan 2002
Posts: 262
Location: New Delhi, India

PostPosted: Tue Jul 09, 2002 8:00 am (15 years, 5 months ago) Reply with QuoteBack to Top

use nl2br() function.

nl2br()
(PHP 3, PHP 4 )

nl2br -- Converts newlines to HTML line breaks
Description

string nl2br (string string)


Returns string with '<BR>' inserted before all newlines.

________________________________
Jayant Kumar
Member of the 4WebHelp Team
Nibble Guru - Computing Queries Demystified
GZip/ Page Compression Test
OfflineView User's ProfileFind all posts by jayantSend Personal MessageVisit Poster's WebsiteYahoo MessengerMSN Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue Jul 09, 2002 8:30 am (15 years, 5 months ago) Reply with QuoteBack to Top

Note: in the newer versions of PHP, it will return an XHTML compliant tag (ie: <br />).

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
craig
Junior WebHelper
Junior WebHelper


Joined: 09 Jul 2002
Posts: 3

PostPosted: Tue Jul 09, 2002 12:03 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Thanks a lot for the help, I'll give it a go Very Happy
OfflineView User's ProfileFind all posts by craigSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.047787 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme