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
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
Link to comment
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!!!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.