SirChick Posted July 27, 2008 Share Posted July 27, 2008 Not sure how this is happening, so if you could tell me which function is missiong/or which is one i am using is causing it ... could you point it out. My input for a paragraph has: <?php $NewMessage = mysql_real_escape_string(stripslashes($_POST['post_box'])); ?> Then output is: <?php //grab data from field $Output = ucfirst(nl2br(strip_tags($Message))); $Message = BBCode($Output); echo $Message; ?> Say i had: Hello there Hello there As an input it then echo's on my forum as: Hello there<br /> <br />Hello there These <br /> should not show...and should act as an actual new line. Thanks in advanced. Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/ Share on other sites More sharing options...
MFHJoe Posted July 27, 2008 Share Posted July 27, 2008 Sorry mate I really don't understand the problem. Could you elaborate? Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600972 Share on other sites More sharing options...
KevinM1 Posted July 27, 2008 Share Posted July 27, 2008 I'm not 100% sure on what you're asking, but the <br> tags are being placed in the output by the nl2br() function. It quite literally means transform any newlines (nl) into (2) line break tags (br). Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600974 Share on other sites More sharing options...
SirChick Posted July 27, 2008 Author Share Posted July 27, 2008 Sorry guys.. Re-edited it.... i was putting <br /> in and it was making a new line rather than showing what i mean, i guess i must of looked a bit mental then ! Re-look at the last part Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600975 Share on other sites More sharing options...
SirChick Posted July 27, 2008 Author Share Posted July 27, 2008 I'm not 100% sure on what you're asking, but the <br> tags are being placed in the output by the nl2br() function. It quite literally means transform any newlines (nl) into (2) line break tags (br). Hmm, yeh but naturally that is so the format of the output remains the same as in the input...hwo ever the format is slow because rather than echo'in the break lines and actually creating a new line, it is showing the break line as a string... which means the format is then lost. Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600979 Share on other sites More sharing options...
MFHJoe Posted July 27, 2008 Share Posted July 27, 2008 Could it be something in the BBCode function? I tried: $Message = "Hello there\n\nHello there"; $Output = ucfirst(nl2br(strip_tags($Message))); echo $Output; ?> And it seemed to work fine so it's probably the BBCode function. Try getting rid of mysql_real_escape_string (temporarily) and see if that makes a difference - I'm not hopeful about that one though. I'd put my money on BBCode. Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600982 Share on other sites More sharing options...
SirChick Posted July 27, 2008 Author Share Posted July 27, 2008 Well this is my BBCode: <?php //bb code fucntion function BBCode($BB){ $BBCode = array("&" => "&", "<" => "<", ">" => ">", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>", $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } ?> Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600985 Share on other sites More sharing options...
MFHJoe Posted July 27, 2008 Share Posted July 27, 2008 Yep, that's it. It's replacing < with < and > with > which is messing with your HTML. You could change BBCode to: <?php //bb code fucntion function BBCode($BB){ $BBCode = array("&" => "&", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>", $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } ?> And that should fix things up. Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-600987 Share on other sites More sharing options...
SirChick Posted July 27, 2008 Author Share Posted July 27, 2008 Excellent! Worked a treat! Thank You Link to comment https://forums.phpfreaks.com/topic/116871-solved-ltbrgt-being-echod-from-input/#findComment-601000 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.