28
« en: 16 de Julio de 2008, 22:08:29 pm »
Hola, este es mi segundo post, pero mas o menos entiendo algo del tema, y bueno, tengo una web que tiene un sistema de noticias, y quiero que esa web tenga BBcode y Smiller, he estado tratando de usar un código que creo westwest, pero, me sale error, el ya me a estado ayudando y nada :S, este es el código:
funciones.php
<?php // abrimos php
function bbcode($texto) { // creamos la función
// $texto = str_replace("PALABRAAREEMPLAZAR","REEMPLAZODELAPALABRA", $texto);
// El codigo de arriba no funcionaria por k esta como comentario ya que hemos usado doble /
$texto = str_replace("[b]","<b>", $texto);
$texto = str_replace("[/b]","</b>", $texto);
$texto = eregi_replace("\\[url=http://([^\\[]*)\\]([^\\[]*)[/url],'<a href="1">\\2</a>', $texto");
}
return $texto; // indicamos k la funcion devuelva la variable $texto
?> // cerramos PHP
y este es el código de mi web, donde tengo las noticias:
index.php
<?php
include ('funciones.php');
echo bbcode($texto);
$config['host'] = 'localhost';
$config['user'] = '...';
$config['pass'] = '...';
$config['db'] = '...';
// here is the start html, <html><body> for example
$start = '<html><head><title>News Flash</title></head><body bgcolor="#ffffff">';
// here is the end html that is put to document
$end = '</body></html>';
// news template
$tpl = '<font color ="#FFFBF0" size="1" Font="Verdana"><font face="Verdana">
<!--//%t=Date-->
<!--//%s=Title or Subject-->
<!--//%n=News-->
<!--//%a=User or Posted by-->
<b>%t - %s</b><br>
<br>
%n
<br>
<br>
<b>Por %a</b>
<br>
<HR size="1" align="right" width="100%" color="7D889A">
<br>
</font> ';
echo $start;
mysql_connect($config['host'], $config['user'], $config['pass']) or die('Connection failed');
mysql_select_db($config['db']) or die('DB selection failed');
$max = mysql_fetch_array(mysql_query('SELECT MAX(id) FROM wootnews'));
$max = $max['MAX(id)']+1;
while($result = mysql_fetch_array(mysql_query('SELECT * FROM wootnews WHERE id<' . $max . ' ORDER BY id DESC;')))
{
echo str_replace(Array('%t', '%a', '%n', '%s'), Array($result['date'], $result['name'], $result['message'], $result['subject']), $tpl);
$max = $result['id'];
}
echo bbcode($end);
?>
Puse el codigo como me habían dicho, pero sale lo mismo
Que puede ser??