Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/12/2003, 13:54
Volrath
 
Fecha de Ingreso: septiembre-2003
Ubicación: Pirexia
Mensajes: 150
Antigüedad: 20 años, 7 meses
Puntos: 1
Urgente, Ayuda!

A ver si me pueden ayudar con esto, estoy haciendo un formulario tipo el de un foro, y quiero que cuando el usuario escriba un texto entre [ CODE ] y [ /CODE ] (que usualmente esto es utilizado para escribir un codigo) ser resalten a color todo lo escrito en php.

se ke esto se puede hacer con highlight_string(); pero no me funciona. yo hice algo asi

Código PHP:
<?
$conexion 
mysql_connect("localhost","root","pass");
mysql_select_db("base",$conexion);
//------------------------------------------------

function bbcodes($comment) {

$comment ereg_replace('\[code\](.*)\[/code\]',"<table width=95% cellspacing=0 cellpadding=0 border=0 bgcolor=e2e2e2 align=center><tr><td>".highlight_string("<? echo date(\"d/m/Y\"); ?>")."</td></tr></table>",$comment);

$comment nl2br($comment);
    
    return 
$comment;
    
// de la function.

//------------------------------------------------
if (isset($go)) {
    
$comentario bbcodes($_POST[comentario]);
    
mysql_query("INSERT INTO comentarios (id_coment, nombre, ip, comentario) values ('1', 'Volrath', '155.155.155.55', '$comentario')");
    
header("Location: comentarios.php");
// del if (go)
?>

<html>
<head>
<title>Agregar Comentarios</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
BODY { color: #777777; font-family: Verdana; font-size: 10px; }
TD { color: #777777; font-family: Verdana; font-size: 10px; }
.titulo { font-weight: bold; font-size: 12px; color: #FFFFFF }
</style>
</head>
<body>
<form action="<?=$PHP_SELF?>" method="post" name="form">
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="20" bgcolor="#000099"><div align="center"><span class="titulo">Agregar Comentarios</span></div></td>
  </tr>
  <tr>
    <td><div align="center">
      <textarea name="comentario" cols="70" rows="5"></textarea>
    </div></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC"><div align="center"><input type="submit" name="go" value="Enviar!!"></div></td>
  </tr>
</table></form>
</body>
</html>
pero no me funciona , al tratar de introducir el CODE solo me sale un " 1 " en negro, que no se ke significa :S

espero que me puedan ayudar con esto.
salu2x
__________________
In a world without walls, who needs Windows?

Última edición por Volrath; 22/12/2003 a las 18:57