Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: BBCode nie działa
Forum PHP.pl > Forum > PHP
Dawior
Witam mam taki problem z BBCode na stronie mam taki skrypt:
bbcode.php
  1. <?
  2. function BBCode($tekst){
  3. $tekst = nl2br($tekst);
  4. $tekst = preg_replace("#(.*?)#si",'<b>1</b>',$tekst);
  5. $tekst = preg_replace("#(.*?)#si",'<i>1</i>',$tekst);
  6. $tekst = preg_replace("#(.*?)#si",'<u>1</u>',$tekst);
  7. $tekst = preg_replace("#(.*?)#si",'<s>1</s>',$tekst);
  8. $tekst = preg_replace("#[img](.*?)[/img]#si",'<img src="1" alt="" />',$tekst);
  9. $tekst = preg_replace("#[img=(.*?)](.*?)[/img]#si",'<img src="1" alt="2" />',$tekst);
  10. $tekst = preg_replace("#(.*?)#si", "<A HREF=\"1\" TARGET=\"_blank\">2</A>", $tekst);
  11. $tekst = preg_replace("#[quote](.*?)[/quote]#si",'<blockquote class="cytat">1</blockquote>',$tekst);
  12. $tekst = preg_replace("#[code](.*?)[/code]#si",'<pre>1</pre>',$tekst);
  13. $tekst = htmlspecialchars($tekst);
  14. return($tekst);
  15. }
  16. ?>


index.php

  1. <?
  2. include("bbcode.php");
  3.  
  4. if($_GET['id'] >= 1)
  5. {
  6. $Query='SELECT * FROM news WHERE id="'.mysql_real_escape_string($_GET['id']).'"';
  7. $result = mysql_query($Query) or die (mysql_error());
  8. while ( $row = mysql_fetch_array($result))
  9.  
  10. {
  11.    echo '<table border="0" width="450" cellpadding="0" cellspacing="0" align="center">
  12. <tr><td class="wiadomosci">'.$row['tytul'].'<hr color="008AFF"></td></tr>
  13. <tr><td class="tloinfo">';
  14. echo ''.BBCode($row['dluga']).'';
  15. echo '<div class="info">
  16. </div>
  17. </td></tr>
  18. </table>';
  19. }
  20.  
  21. }
  22. ?>

I jak pisze np [b ]Jakiś tekst[ /b] To nie działa proszę o pomoc. Z góry dziękuję
nospor
w jakim sensie nie dziala? komputer sie pali?

nie zamienia ci [b] na <b>, czy moze zamienia na <b> tlyko ze ty te <b>widzisz jako tekst? Jak to drugie to wina tego:
$tekst = htmlspecialchars($tekst);
smile.gif
Dawior
Nie widać <b> tylko widać takie coś [ b]jaki tam tekst[/b ]

Dobra już działa dzięki temat do zamknięcia!
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.