Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
mysql and blank lines
Old 01-25-2007, 12:04 AM mysql and blank lines
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
hey guys I have a mysql database but in this database you can insert test such as a guestbook or comment board but if the user has pressed enter or put in some blank lines when I echo it to my webpage it puts everything as if there were no newlines or returns how do I have this show the returns and newlines as they were put in?

language is php
__________________
A patch is a piece of software which replaces old bugs with new bugs.

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
 
Register now for full access!
Old 01-25-2007, 12:18 AM Re: mysql and blank lines
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Well, they're probably showing up ( if you right click and "view source" ) they just aren't showing up the way you want them to. PHP runs on the server, and renders to html, which generally ignores white-space. ( Two spaces are the same as one, and a bunch of line-feeds are ignored. )

So the answer is actually pretty simple. You just need to turn the "enter" character into an html line break tag. I don't know PHP very well ( I'm an ASP.NET guy ), so I can't give you the exact code, but you want to run a string replace function over what you pull out of the database, look for character 13, and replace it with the string "<br />" You could shorten that to "<br>" but the first one is more "proper;" either will work.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 01-25-2007, 12:33 AM Re: mysql and blank lines
blackhawkpowers's Avatar
Ultra Talker

Posts: 313
Name: Dustin
Location: GA
Trades: 0
dead on man perfect answer and here is the solution for anyone else with php

$content= str_replace(chr(13),"<br />",$content);

TP for you
__________________
A patch is a piece of software which replaces old bugs with new bugs.

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
blackhawkpowers is offline
Reply With Quote
View Public Profile Visit blackhawkpowers's homepage!
 
Old 01-25-2007, 06:48 PM Re: mysql and blank lines
Skilled Talker

Posts: 62
Name: Daniel
Trades: 0
or....

nl2br($content);
castis is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to mysql and blank lines
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25148 seconds with 12 queries