Tema: Bbcode
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/03/2011, 14:48
villi
 
Fecha de Ingreso: enero-2011
Mensajes: 56
Antigüedad: 13 años, 3 meses
Puntos: 1
Respuesta: Bbcode

encontre un codigo pero no me funciona bien.

lo que hago es traducir el codigo bbcode al html pero no me funciona y no se cual es el problema:


$registros=mysql_query("select * from noticias where id = $id", $conexion) or die("Problemas en el select:".mysql_error());
if ($reg=mysql_fetch_array($registros))
{
function BBcode($mensaje){
$texto = htmlentities(texto);
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url=(.*?)\](.*?)\[\/url\]/is"
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<img src=\"$1\" />",

"<a href=\"$1\" target=\"_blank\">$2</a>"
);
$texto = preg_replace($a, $b, $mensaje);
$texto = nl2br($mensaje);
return mensaje;
}
echo "<p>";
echo "<b>De: </b><a href='ver_perfil.php?nombre=".$reg['de']."'>".$reg['de']."</a><br />";
echo "<b>Escrito el: </b>".$reg['fecha']."<br />";
echo "<b>Categoria: </b>".$reg['categoria']."<br />";
echo "<b>Titulo: </b>".$reg['titulo']."<br />";
echo "<b>Noticia: </b>".$reg['mensaje']."<br />";
echo "</p>";

}