Jump to content

Help with nl2br()


EchoFool

Recommended Posts

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

Link to comment
Share on other sites

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">',

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.