nemesis1931 Posted June 6, 2006 Share Posted June 6, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/11297-dude-wheres-my-whitespace/ Share on other sites More sharing options...
kenrbnsn Posted June 6, 2006 Share Posted June 6, 2006 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 "&nbsp;" (non-breaking space) characters and replace tab characters with either 4 or 8 "&nbsp;" characters. If you go the replace route, you would also have to use the nl2br() function to add "<br>" to each newline character.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11297-dude-wheres-my-whitespace/#findComment-42298 Share on other sites More sharing options...
nemesis1931 Posted June 6, 2006 Author Share Posted June 6, 2006 [!--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!!! Quote Link to comment https://forums.phpfreaks.com/topic/11297-dude-wheres-my-whitespace/#findComment-42299 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.