Jump to content

Dude, wheres my whitespace?


nemesis1931

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!
Link to comment
https://forums.phpfreaks.com/topic/11297-dude-wheres-my-whitespace/
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
[!--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!!!

Archived

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

×
×
  • Create New...

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.