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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
EchoFool Posted February 20, 2008 Author Share Posted February 20, 2008 bump ??? Quote Link to comment 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; } ?> Quote Link to comment 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.