chrisbergr
Erfahrenes Mitglied
problem mit preg_replace
hi ich hab nen schönes kleines cms gemacht .. nur bei der ausgabe der seite habe ich ein problem mit der str_replace, die ich dazu verwenden will, das auch BB Codes funtionieren ...
das problem ist in den 4 zeilen, die ich ausgeklammert habe .. was mein problem ist? ganz einfach, er ändert die bb codes nicht in html befehle um .. ich hoffe mir kann jemand helfen .
THX im Voraus
Edit Caminus: Hab das mal in Code Tags geschrieben, da das Board ansonsten soviel kaputt macht.
hi ich hab nen schönes kleines cms gemacht .. nur bei der ausgabe der seite habe ich ein problem mit der str_replace, die ich dazu verwenden will, das auch BB Codes funtionieren ...
Code:
<?php
$dbTable = "vanessa_seite";
mysql_connect($host,$username,$password) OR die("Can't connect to database");
mysql_select_db("$dbname") or die("Unable to select database");
$result = mysql_db_query ("$dbname","select * from $dbTable where id = '$nummer'");
while ($row = mysql_fetch_array ($result))
{
$id =$row["id"];
$seite =nl2br(htmlentities(stripslashes($row[seite])));
$comment =nl2br(htmlentities(stripslashes($row[comment])));
$comment = str_replace(":)","<img src=\"gfx/smilys/smile.gif\" border=0>",$comment);
$comment = str_replace(":(","<img src=\"gfx/smilys/frown.gif\" border=0>",$comment);
$comment = str_replace(":p","<img src=\"gfx/smilys/tongue.gif\" border=0>",$comment);
$comment = str_replace(";)","<img src=\"gfx/smilys/wink.gif\" border=0>",$comment);
$comment = str_replace(":confused:","<img src=\"gfx/smilys/confused.gif\" border=0>",$comment);
$comment = str_replace(":uiii:","<img src=\"gfx/smilys/eek.gif\" border=0>",$comment);
$comment = str_replace(":zwinker:","<img src=\"gfx/smilys/kewl.gif\" border=0>",$comment);
$comment = str_replace(":nene:","<img src=\"gfx/smilys/nene.gif\" border=0>",$comment);
$comment = str_replace(":hmm:","<img src=\"gfx/smilys/rolleyes.gif\" border=0>",$comment);
$comment = str_replace(":zzz:","<img src=\"gfx/smilys/sleep.gif\" border=0>",$comment);
$comment = str_replace(":D","<img src=\"gfx/smilys/biggrin.gif\" border=0>",$comment);
$comment = str_replace("[ b ]","<b>",$comment);
$comment = str_replace("[ /b ]","</b>",$comment);
$comment = str_replace("[ i ]","<i>",$comment);
$comment = str_replace("[ /i ]","</i>",$comment);
$comment = str_replace("[ u ]","<u>",$comment);
$comment = str_replace("[ /u ]","</u>",$comment);
//$comment=preg_replace("/[ img](.*)[ /img]/iUms","<center><img src=\"\1\"></center>",$comment);
//$comment=preg_replace("/[ email](.*)[ /email]/msiU", "<a href=\"mailto:\1\">\1</a>", $comment);
//$comment=preg_replace("/[ url](.*)[ /url]/iUms","<a href=\"\1\" target=_blank>\1</a>",$comment);
//$comment=preg_replace("/[ url](.*)](.*)[ /url]/iUms","<a href=\"\1\" target=_blank>\2</a>",$comment);
echo"<p>$comment</p>";
}
?>
das problem ist in den 4 zeilen, die ich ausgeklammert habe .. was mein problem ist? ganz einfach, er ändert die bb codes nicht in html befehle um .. ich hoffe mir kann jemand helfen .
THX im Voraus
Edit Caminus: Hab das mal in Code Tags geschrieben, da das Board ansonsten soviel kaputt macht.
Zuletzt bearbeitet von einem Moderator: