I started a comments page on my website and the comments work fine and go through. But after you submit the comment the out put displays like this on my webpage:

comments:
"heartbeaker" by: jamika
@ 12:30:00 am on March 11, 2010.
Fear<br /> There are two flip sides, to every angle in life. <br /> Some ride these angles like wheels on a bike.<br /> Others are afraid, that the world ,will see their insides.<br /> So they cower, head bowed, and runaway from the light.<br /> <br />

How do i get the </br> to not show up when my user submits there comment. I assume their hitting the enter key. I dont want it to so the HTML.

Please Help thanks

where ever you print our comment use html_entity_decode(); function i.e.

echo html_entity_decode($comment);

It's an echo, so when you display the comments, you use the line liam put.

It's an echo, so when you display the comments, you use the line liam put.

here is the code im working with. where should i put liam echo code.

//connect to your database


//query comments for this page of this article
$inf = "SELECT * FROM `comments` WHERE page = '".stripslashes($_SERVER)."' ORDER BY time ASC";
$info = mysql_query($inf);
if(!$info) die(mysql_error());

$info_rows = mysql_num_rows($info);
if($info_rows > 0) {
echo '<h5>Comments:</h5>';
echo '<table width="95%">';

while($info2 = mysql_fetch_object($info)) {
echo '<tr>';
echo '<td>"'.stripslashes($info2->subject).'" by: <a href="'.$info2->contact.'">'.stripslashes($info2->username).'</a></td> <td><div align="right"> @ '.date('h:i:s a', $info2->time).' on '.$info2->date.'</div></td>';
echo '</tr><tr>';
echo '<td colspan="2"> '.stripslashes($info2->comment).' </td>';
echo '</tr>';
}//end while
echo '</table>';
echo '<hr width="95%" noshade>';
} else echo 'No comments for this page. Feel free to be the first <br>';

if(isset($_POST)) {
if(!addslashes($_POST)) die('<u>ERROR:</u> you must enter a username to add a comment.');
if(!addslashes($_POST)) die('<u>ERROR:</u> enter contact method in contact field.');
if(!addslashes($_POST)) die('<u>ERROR:</u> enter a subject to your comment.');
if(!addslashes($_POST)) die('<u>ERROR:</u> cannot add comment if you do not enter one!?');

echo '<td colspan="2"> '.stripslashes($info2->comment).' </td>';

Displays the comment right? well change it to...

echo '<td colspan="2"> '.html_entity_decode(stripslashes($info2->comment)).' </td>';

That should work.

That should work.

nope still has a break</br> after every line. im going to show you the whole code maybe its something at the bottom.

<? ob_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>www.PoetryBattles.com/poetry works.html</title>
<style type="text/css">
#header {
    position:absolute;
    left:100px;
    top:0px;
    width:800px;
    height:17px;
    z-index:1;
    background-color: #0d0600;
}
#content {
    position:absolute;
    left:4px;
    top:1px;
    width:1161px;
    height:4095px;
    z-index:2;
    background-repeat: no-repeat;
    background-image: url(poetryworks%20bg.png);
}
#cgi {
    position: absolute;
    left: -84px;
    top: 470px;
    width: 553px;
    height: 428px;
}
#form {
    position: absolute;
    left: 282px;
    top: 190px;
    width: 166px;
    height: 47px;
}
#links22 {
    position: absolute;
    left: 759px;
    top: 4066px;
    width: 68px;
    z-index: 4;
}
#link33 {
    position: absolute;
    left: 835px;
    top: 4065px;
    width: 77px;
    z-index: 5;
}
#footer {
    position:absolute;
    left:104px;
    top:4149px;
    width:1030px;
    height:50px;
    z-index:3;
}
#pic {
    height: 465px;
    width: 334px;
    position: absolute;
    left: 532px;
    top: 395px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    text-align: left;
}
body {
    text-align: left;
    background-color: #0d0600;
}
#master {
    width: 1100px;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
    position: relative;
    left: 0px;
    top: 0px;
    background-color: #0d0600;
}
#apDiv1 {
    position:absolute;
    left:1078px;
    top:592px;
    width:2px;
    height:0px;
    z-index:1;
}
#scull {
    position: absolute;
    height: 20px;
    width: 120px;
    left: 463px;
    top: 251px;
}
#apDiv2 {
    position:absolute;
    left:649px;
    top:515px;
    width:311px;
    height:136px;
    z-index:1;
}
a:link {
    color: #996633;
    text-decoration: none;
}
a:visited {
    color: #996633;
    text-decoration: none;
}
a:hover {
    color: #663300;
    text-decoration: underline;
}
a:active {
    color: #996633;
    text-decoration: none;
}
#chick {
    position: absolute;
    height: 19px;
    width: 136px;
    left: 718px;
    top: 252px;
}
#lawyer {
    position: absolute;
    height: 22px;
    width: 129px;
    left: 583px;
    top: 250px;
}
#blog {
    position: absolute;
    height: 15px;
    width: 112px;
    left: 633px;
    top: 4066px;
}
#message {
    position: absolute;
    height: 21px;
    width: 105px;
    left: 862px;
    top: 253px;
    z-index: 7;
}
#rights {
    position: absolute;
    height: 15px;
    width: 44px;
    left: 334px;
    top: 4069px;
    z-index: 8;
}
#muffy {
    position: absolute;
    height: 20px;
    width: 93px;
    left: 969px;
    top: 251px;
}
#welcome {
    position: absolute;
    height: 20px;
    width: 43px;
    left: 409px;
    top: 249px;
}
#tilartwork {
    position: absolute;
    height: 15px;
    width: 105px;
    left: 390px;
    top: 4068px;
}
#beauty {
    position: absolute;
    height: 15px;
    width: 121px;
    left: 509px;
    top: 4068px;
    z-index: 3;
}
.style44 {
    color: #996633;
    font-family: Verdana;
    font-size: 14px;
}
.style45 {font-family: "Trebuchet MS"}
.style46 {
    font-size: 16px
}
.style49 {font-family: "Trebuchet MS"; color: #996633; font-size: 14px; }
body,td,th {
    font-family: Trebuchet MS;
    font-size: 16px;
    color: #993300;
}
h1 {
    font-size: 18px;
    color: #00FFFF;
}
.style57 {color: #00FFFF}
a {
    font-size: 16px;
}
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>

<div id="master">

<div id="header"></noscript>
  </div>


<div id="content">
  <div class="style49" id="blog"><a href="published poets.html">Published Poets</a></div>
 <div class="style49" id="tilartwork"><a href="poetry works page.html">Poetry Works</a></div>
 <div class="style44" id="welcome">
   <a href="main.php" class="style45">Home</a></div>
 <div class="style44" id="muffy">
   <a href="about us.html" class="style45">About Us</a></div>
 <div class="style44" id="lawyer">
   <a href="battle page.html" class="style45">Battles Grounds</a></div>


 <div class="style45" id="scull">
   <a href="comments.php" class="style46">Poetry Works</a></div>
 <div class="style44" id="chick">
   <a href="published poets.html" class="style45">Published Poets</a></div>

<?php
    //Local copy

    function BBCode($Text)
        {
            // Replace any html brackets with HTML Entities to prevent executing HTML or script
            // Don't use strip_tags here because it breaks [url] search by replacing & with amp
            $Text = str_replace("<", "&lt;", $Text);
            $Text = str_replace(">", "&gt;", $Text);



            // Set up the parameters for a URL search string
            $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
            // Set up the parameters for a MAIL search string
            $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";

            //Non BB URL Search
            //$Text = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "<a href=\"\\1://\\2\\3\" target=\"_blank\" target=\"_new\">\\1://\\2\\3</a>", $Text);
            //$Text = eregi_replace("(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", "<a href=\"mailto:\\1\" target=\"_new\">\\1</a>", $Text);
            if (substr($Text,0, 7) == "http://"){
            $Text = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "<a href=\"\\1://\\2\\3\">\\1://\\2\\3</a>", $Text);
             // Convert new line chars to html <br /> tags
            $Text = nl2br($Text);
            } else { 
            // Perform URL Search
            $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="javascript:go(\'$1\',\'new\')">$1</a>', $Text);
            $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="javascript:go(\'$1\',\'new\')">$2</a>', $Text);
            //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
             // Convert new line chars to html <br /> tags
            $Text = nl2br($Text);
            }
            // Perform MAIL Search
            $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
            $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);

            // Check for bold text
            $Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text);

            // Check for Italics text
            $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="italics">$1</span>',$Text);

            // Check for Underline text
            $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span class="underline">$1</span>',$Text);

            // Check for strike-through text
            $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span class="strikethrough">$1</span>',$Text);

            // Check for over-line text
            $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text);

            // Check for colored text
            $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text);

            // Check for sized text
            $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text);

            // Check for list text
            $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
            $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
            $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>' ,$Text);
            $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
            $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
            $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
            $Text = str_replace("[*]", "<li>", $Text);

            // Check for font change text
            $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);

            // Declare the format for [code] layout
            $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="quotecodeheader"> Code:</td>
                                </tr>
                                <tr>
                                    <td class="codebody">$1</td>
                                </tr>
                           </table>';
            // Check for [code] text
            $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text);

            // Declare the format for [quote] layout
            $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td class="quotecodeheader"> Quote:</td>
                                </tr>
                                <tr>
                                    <td class="quotebody">$1</td>
                                </tr>
                           </table>';

            // Check for [code] text
            $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is","$QuoteLayout", $Text);

            // Images
            // [img]pathtoimage[/img]
            $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $Text);

            // [img=widthxheight]image source[/img]
            $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src="$3" height="$2" width="$1">', $Text);

            return $Text;
        }
?>
 <div id="form">  
 <div id="cgi">
<?php

$database[dbserver]="localhost";
$database[dbuser]="";
$database[dbname]="";
$database[dbpass]="";
$table ="comments";

$connect = mysql_connect($database['dbserver'], $database['dbuser'], $database['dbpass']);

$select= mysql_select_db($database['dbname']);

//connect to your database


//query comments for this page of this article
$inf = "SELECT * FROM `comments` WHERE page = '".stripslashes($_SERVER['REQUEST_URI'])."' ORDER BY time ASC";
$info = mysql_query($inf);
     if(!$info) die(mysql_error());

   $info_rows = mysql_num_rows($info);
if($info_rows > 0) {
   echo '<h5>Comments:</h5>';
   echo '<table width="95%">';

while($info2 = mysql_fetch_object($info)) {  
echo '<tr>'; 
echo '<td>"'.stripslashes($info2->subject).'" by: <a href="'.$info2->contact.'">'.stripslashes($info2->username).'</a></td> <td><div align="right"> @ '.date('h:i:s a', $info2->time).' on '.$info2->date.'</div></td>';
echo '</tr><tr>';
echo '<td colspan="2"> '.html_entity_decode(stripslashes($info2->comment)).' </td>';
echo '</tr>';
}//end while
echo '</table>';
echo '<hr width="95%" noshade>';
} else echo 'No comments for this page. Feel free to be the first <br>';

if(isset($_POST['submit'])) {
  if(!addslashes($_POST['username'])) die('<u>ERROR:</u> you must enter a username to add a comment.');
  if(!addslashes($_POST['contact']))  die('<u>ERROR:</u> enter contact method in contact field.');
  if(!addslashes($_POST['subject']))  die('<u>ERROR:</u> enter a subject to your comment.');
  if(!addslashes($_POST['comment']))  die('<u>ERROR:</u> cannot add comment if you do not enter one!?');


//this is for a valid contact
  if(substr($_POST['contact'],0,7) != 'mailto:' && !strstr($_POST['contact'],'//')) {
              if(strstr($_POST['contact'],'@'))
                $_POST['contact'] = "mailto:".$_POST['contact']."";
              else
                $_POST['contact'] = "http://".$_POST['contact']."";
} //end valid contact

//try to prevent multiple posts and flooding...
$c = "SELECT * from `comments` WHERE ip = '".$_SERVER['REMOTE_ADDR']."'";
  $c2 = mysql_query($c);
     while($c3 = mysql_fetch_object($c2)) {
      $difference = time() - $c3->time;
     if($difference < 300) die('<u>ALERT:</u> '.$c3->username.', You have already commented earlier; if you have a question, try the forums!<BR>');
} //end while
//add comment
$q ="INSERT INTO `comments` (article_id, page, date, time, username, ip, contact, subject, comment) VALUES ('".$_GET['id']."', '".$_POST['page']."', '".$_POST['date']."', '".$_POST['time']."', '".addslashes(htmlspecialchars($_POST['username']))."', '".$_SERVER['REMOTE_ADDR']."', '".addslashes(htmlspecialchars($_POST['contact']))."', '".addslashes(htmlspecialchars($_POST['subject']))."', '".addslashes(htmlspecialchars(nl2br($_POST['comment'])))."')";

$q2 = mysql_query($q);
  if(!$q2) die(mysql_error());

//refresh page so they can see new comment
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . "#comments");
} else 
{  //display form
?>
<?php
$line_break=nl2br($_POST['text']);
echo $line;
?>
<form name="comments" action="<? $_SERVER['PHP_SELF']; ?>" method="post">

<input type="hidden" name="page" value="<? echo($_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="date" value="<? echo(date("F j, Y.")); ?>">
<input type="hidden" name="time" value="<? echo(time()); ?>">

<table width="90%" border="0" cellspacing="0" cellpadding="0">
   <tr>
      <td><div align="right">Username:   </div></td>
       <td><input name="username" type="text" size="30" value=""></td>
   </tr>
    <tr>
      <td><div align="right">Contact:   </div></td>
      <td><input type="text" name="contact" size="30" value=""> <i>(email or url)</i></td>
    </tr>
    <td><div align="right">Subject:   </div></td>
    <td><input type="text" name="subject" size="30" value=""></td>
    </tr>
    <tr>
      <td><div align="right">Comment:   </div></td>
      <td><textarea name="comment" cols="45" rows="5" wrap="VIRTUAL"></textarea></td>
    </tr>
    <tr>
      <td></td>
      <td colspan="2"><input type="reset" value="Reset Fields">     
        <input type="submit" name="submit" value="Add Comment"></td>
    </tr>
  </table>
</form>
<?
} // end else
?> 
 </div>
</div>
 <div class="style49" id="link33"><a href="Contact Us.html">Contact Us</a></div>
<div class="style49" id="links22"><a href="about us.html">About Us</a></div>
 <div class="style49" id="rights"><a href="index.html">Home</a></div> 
 <div class="style44" id="message">
  <a href="Contact Us.html" class="style45">Contact Us</a></div>
 <div class="style49" id="beauty"><a href="battle page.html">Battles Grounds</a></div>
</div>


<div id="footer"></div>
</div>

</body>

</html>
<? ob_flush(); ?>

Hey, it works, i took that bbc function out and it works.
I think im in love with you.

thanks so much

lol and use code tags next time, then we people might love you too :D

in my code what can i do so that my comments page will only accept 50 comments

and maybe add the next one 101 to a next page-->
umm

what im trying to say is

I want to use a code that allows me to control how many comments that came be submitted on my comments.php page. And maybe after 50 or so it will transfer them to a new page once you hit the next button and so on and so fourth
and have a back button. also.
ive seen it on forum like this one but have not a clue how to set it up.

If you google "Pagination in PHP" or even search for it on this site - it will give you a rough idea of how to achieve what you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.