bb code I guess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

bb code I guess

Post by Jim_Bo »

Hi,

I have been trying to get some bb code to work for
[/qoute]

when I display the quote message I have a few problems ..

within the blockquote there seems to be a couple invisible <br> before the word Quote: is displayed .. its printed well below the blockquote border.

Also when the data is echoed back I cant get nl2br to work .. its all displayed in a single line.

Code: Select all

//variables
       $replymessage = $row["message"];
	$quote = '[quote]';
	$quote1 = '[/quote]';

 $message = ereg_replace('\[quote]','<blockquote style="width: 80%; background-color: #CCCCCC; border: 1px solid #000000;">
  <table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
      <td><font class="txt"><b>Quote</b>:<br>
', $row["message"]); $message = ereg_replace('\[/quote][/quote]', '</font></td>
    </tr>
  </table>
</blockquote><br>', $message);
then called displayed on the page as:

Code: Select all

<?php echo (nl2br($message)); ?>
Other problem is .. that when I echo the quote /quote back within a textarea again it is all in one line .. and if there is a " within the text the quote fails example:

quote bla bla bla "

rather than:

quote bla
bla

bla "/quote

as the original message being quoted is stored.

in the reply code:

Code: Select all

// variables
$replymessage = $_GET['replymessage'];
$quote = $_GET['quote'];
$quote1 = $_GET['quote1'];

//echo back in textarea as

<textarea name=\"message\" cols=\"40\" rows=\"10\" class=\"input-box\"><? echo $quote; ?><? echo nl2br($replymessage); ?><? echo $quote1; ?></textarea>
How should the code be to work properly?

Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

OK...

The "invisble <br />" problem is not invisible <br /> tags it is in fact CSS.

<blockquote> has internal padding (and margin too).

You need to specify what amount of padding you want by using some CSS.

Use addslashes() to prevent the trucated output when " is hit ;-)
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

tried addslashes:

Code: Select all

<textarea name="message" cols="40" rows="10" class="input-box"><? echo $quote; ?><? echo addslashes(nl2br($replymessage)); ?><? echo $quote1; ?></textarea>
I get

[quote]bla \\\\ bla bla

rather than

[quote]bla \ bla bla " bla[/quote.]

Also nl2br isnt working ..

I have tried adding

margin: 5px 5px 5px 5px 5px;

to the blockquote .. and still it is way down the page ..

?

Thanks
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

*Bump*

:idea: ?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Can you posts the RAW HTML output of the script please.... rather than whatb you seen on the page itself.

Also.... it's not margin, it's padding :wink: (Namely "padding-top, and padding-bottom")
Post Reply