EchoFool Posted February 19, 2008 Share Posted February 19, 2008 I have a problem with my script. I input data using a function to maintain its line structure... This part works fine... $QuoteMessage = nl2br($row['Message']); $UPDATE2 = mysql_query("INSERT INTO posts (ThreadID,UserID,Message,CreatedOn) VALUES ('$Thread','{$_SESSION['Current_User']}','$Post','$Date')") Or die(mysql_error()); How ever if i want to echo it with my function involved i get this: Test<br /> test<br /> <br /> <br /> <br /> Test<br /> Test<br /> e<br /> <br /> tete<br /> w000 This is how it should look Test<br /> test<br /> <br /> <br /> <br /> Test<br /> Test<br /> e<br /> <br /> tete<br /> w000 As you can see its not doing the lines but its echo'in the actual layout html code. This is what i have for my output: <?php function BBCode($BB){ $BBCode = array("&" => "&", "<" => "<", ">" => ">", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>", "[Quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>", "[quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>", "[quote]" => "<div class='quotetop'>QUOTE</div><div class='quotemain'>", "[/Quote]" => "</div><br>", "[/quote]" => "</div><br>", "[/quote]" => "</div><br>", "[sQ]" => "<div class='quotetop'>QUOTE <span class=PositiveMoney> ", "[sQ2]" => "</span></div><div class='quotemain'>", "<br />" => "",); $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } //query get message stuff here //------------------------ $newString = BBCode($Message); $newString = str_replace('<br />', '', $newString); echo $newString;?> What did i do wrong? Link to comment https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/ Share on other sites More sharing options...
darkfreaks Posted February 19, 2008 Share Posted February 19, 2008 remove nl2br or else you will get line breaks after each line. Link to comment https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/#findComment-471037 Share on other sites More sharing options...
EchoFool Posted February 19, 2008 Author Share Posted February 19, 2008 Yeh but then i loose the format of the input... say the input was : test test Test and i removed it.. it comes out like test test test Link to comment https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/#findComment-471072 Share on other sites More sharing options...
EchoFool Posted February 20, 2008 Author Share Posted February 20, 2008 bump ??? Link to comment https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/#findComment-471269 Share on other sites More sharing options...
darkfreaks Posted February 20, 2008 Share Posted February 20, 2008 <?php function remove_extra_linebreaks($string) { $new_string=urlencode ($string); $new_string=ereg_replace("%0D", " ", $new_string); $new_string=urldecode ($new_string); return $new_string; } ?> Link to comment https://forums.phpfreaks.com/topic/91963-help-with-function-and-breakline-output/#findComment-471284 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.