Jump to content


Photo

Dude, wheres my whitespace?


  • Please log in to reply
2 replies to this topic

#1 nemesis1931

nemesis1931
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 June 2006 - 04:01 AM

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!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 June 2006 - 04:23 AM

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

#3 nemesis1931

nemesis1931
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 06 June 2006 - 04:29 AM

[!--quoteo(post=380485:date=Jun 5 2006, 11:23 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 5 2006, 11:23 PM) View Post[/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!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users