MoFish Posted June 4, 2006 Share Posted June 4, 2006 i have a text area on my page, but when i do a new line using return, it is not displaying a new line on the output to screen. how can i successfully use returns so it is displayed in paragraphs for example.im using the following:[b]$message = $_POST['messagebox'];[/b][b]<textarea name="messagebox" cols="40" rows="5" style="width:300px"></textarea>[/b]thanks again, mofish Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/ Share on other sites More sharing options...
AndyB Posted June 4, 2006 Share Posted June 4, 2006 When you retrieve it, display it using the nl2br() function:[code]echo nl2br($message);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41854 Share on other sites More sharing options...
SetLar8 Posted June 4, 2006 Share Posted June 4, 2006 Hi,I have this same problem and am using the nl2br function.But if someone sends a message with one or more single quotes in it i get the following:typed in textarea: foo isn't bardisplayed in HTML: foo isn\\\'t barFor some reason 3 backslashes are added before the quote every time and this happends to every quote in the message.e.g.He's it's she's = He\\\'s it\\\'s she\\\'sHow can i stop this properly?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41858 Share on other sites More sharing options...
Daguse Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo(post=380032:date=Jun 4 2006, 05:27 PM:name=SetLar8)--][div class=\'quotetop\']QUOTE(SetLar8 @ Jun 4 2006, 05:27 PM) [snapback]380032[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,I have this same problem and am using the nl2br function.But if someone sends a message with one or more single quotes in it i get the following:typed in textarea: foo isn't bardisplayed in HTML: foo isn\\\'t barFor some reason 3 backslashes are added before the quote every time and this happends to every quote in the message.e.g.He's it's she's = He\\\'s it\\\'s she\\\'sHow can i stop this properly?Thanks.[/quote]Try using $message = nl2br(htmlentities($message));htmlentities($message) should get ride of the \\\ problem. Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41861 Share on other sites More sharing options...
SetLar8 Posted June 4, 2006 Share Posted June 4, 2006 no, that didnt help.Any other ideas?Thanks for your help anyway Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41871 Share on other sites More sharing options...
redarrow Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo(post=380045:date=Jun 4 2006, 10:20 PM:name=SetLar8)--][div class=\'quotetop\']QUOTE(SetLar8 @ Jun 4 2006, 10:20 PM) [snapback]380045[/snapback][/div][div class=\'quotemain\'][!--quotec--]no, that didnt help.Any other ideas?Thanks for your help anyway[/quote][code]<?$message = nl2br(htmlentities($message));$goawaybackslash=str_replace("\\\","",$message);echo $goawaybackslash;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41880 Share on other sites More sharing options...
SetLar8 Posted June 4, 2006 Share Posted June 4, 2006 Hi,I thought of that but it doesnt work.It will accept "\\" but not "\\\", try it in dreamweaver.I really cannot understand it, any more help will be really apreciated. Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41898 Share on other sites More sharing options...
SetLar8 Posted June 5, 2006 Share Posted June 5, 2006 Hi,Following the above i have found the following:When i submit the message first time there is only 1 backslash "\'"But when i pass the variable to another page 2 more are added.You can check this out here: [a href=\"http://www.maxiehost.com/uk/support.htm\" target=\"_blank\"]http://www.maxiehost.com/uk/support.htm[/a]When entering the message click send, on the next screen you can see the message with only one backslash for each single quote. when you enter the verification code and submit there are then 2 more added to each single quote. Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41910 Share on other sites More sharing options...
samshel Posted June 5, 2006 Share Posted June 5, 2006 It might be because of "magic_quotes_gpc" setting on in your php.ini. it automatically adds slashes..you can try using stripslashes()....hth Quote Link to comment https://forums.phpfreaks.com/topic/11189-text-area-new-lines/#findComment-41959 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.