Jump to content

Archived

This topic is now archived and is closed to further replies.

nemesis1931

Dude, wheres my whitespace?

Recommended Posts

Hey there.



I'm saving a block of text into MySQL.

When I read it back using PHP it strips all the whitespace characters and line breaks.

I would like to have them back!

[img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
Any idea how to do this? I can't find it in search on php.net phpbuilder or this site..

is it because of the mysql_real_escape..() function..

$_POST seems to hold all the whtie space, but after its loaded into MySQL i lose it.

please help!

Share this post


Link to post
Share on other sites
It's not PHP's fault, it's how browsers display HTML. All white space is collapsed to one space, as are newline characters. You can either display your data between "<pre></pre>" tags or replace all spaces with "&amp;nbsp;" (non-breaking space) characters and replace tab characters with either 4 or 8 "&amp;nbsp;" characters. If you go the replace route, you would also have to use the nl2br() function to add "&lt;br>" to each newline character.

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=380485:date=Jun 5 2006, 11:23 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 5 2006, 11:23 PM) [snapback]380485[/snapback][/div][div class=\'quotemain\'][!--quotec--]
It's not PHP's fault, it's how browsers display HTML.

Ken
[/quote]


Oh. that sucks.

thanks for your insight.

2 cookies for u!!!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.