EchoFool Posted June 17, 2010 Share Posted June 17, 2010 Hey, When a user posts a message the next page shows it as a preview before confirming.... but for some reason the nl2br function doesn't work... This is what i have: <?php function local($BB){ //bb code fucntion $BBCode = array( "&" => "&", "[title]" => '<center><span class="header">', "[/title]" => '</span></center>', "[p]" => '<p align"left">', "[/p]" => '</p><br><br>', "[i]" => '<i>', "[/i]" => '</i>', "[b]" => '<b>', "[/b]" => '</b>' ); $Message = str_replace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } $Message = SQLskip($_POST['letter']); ?> <span class="Negative"><blink>NOTE:</blink> This is just a preview!</span><br><br> <div id="messagebox"><br><br> <?php echo nl2br(local($Message));?> <br><br> </div> But the page shows : test\r\n\r\ntest Any idea why? Thanks Quote Link to comment Share on other sites More sharing options...
EchoFool Posted June 19, 2010 Author Share Posted June 19, 2010 bump Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 19, 2010 Share Posted June 19, 2010 Kind of hard to decypher what the problem is when a) I have no clue what you are using as an input for testing and b) you are invoking a function called SQLskip() which isn't displayed here. For all I know the problem is with that function. I'm too lazy to test, but there is an error in your BB code parser. I doubt it is the cause of your problem, but who knows. This "[p]" => '<p align"left">', Should be this "[p]" => '<p align="left">', Quote Link to comment Share on other sites More sharing options...
Alex Posted June 19, 2010 Share Posted June 19, 2010 What does SQLskip() do? Quote Link to comment Share on other sites More sharing options...
EchoFool Posted June 19, 2010 Author Share Posted June 19, 2010 My input is : test test MY SQLSkip function: //SQL protection function SQLskip($Var){ return mysql_real_escape_string(stripslashes($Var)); } Quote Link to comment Share on other sites More sharing options...
Alex Posted June 19, 2010 Share Posted June 19, 2010 If you're not inserting it into the database, and just previewing it you don't need to escape the data for MySQL yet. That's what's causing your problem. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted June 19, 2010 Author Share Posted June 19, 2010 I use the SQLskip function for both getting from the database and inserting just to be on the v.safe side - i don't think it would effect the breaklines in anyway though 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.