Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/08/2011, 18:00
alfon02
 
Fecha de Ingreso: marzo-2011
Mensajes: 9
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Error con pagina

Hola, los primero, muchas gracias a los dos por responderme tan rapido. A continuación os pongo el codigo:

enviar-mensaje.php:

<?php
session_start();
include('../../conectar.php');
$usuario = mysql_real_escape_string(htmlspecialchars($_SESSIO N['user']));
if(isset($usuario)) {
$mensaje = mysql_real_escape_string(htmlspecialchars($_POST['mensaje']));
if(isset($mensaje)) {
if(isset($usuario)) {

// Comandos
// Comandos Acciones
// Borrar Mensajes:
if($mensaje == "/borrar" && $_SESSION['rol'] == "3"){
mysql_query("TRUNCATE TABLE tagharrypotter");
}
else{

$act = "INSERT INTO tagharrypotter (de,mensaje) values ('".$usuario."','".$mensaje."')";
@mysql_query($act);
}
}
}
}
include("mensajes.php");
?>

Y en :

mensajes.php:

<?php
include('../../conectar.php');
$usuario = mysql_real_escape_string(htmlspecialchars($_SESSIO N['user']));
$query = "SELECT * FROM `usuarios` WHERE usuario = '".$usuario."'";
$resp = @mysql_query($query);
$user = @mysql_fetch_array($resp);

$chat1 = mysql_query("SELECT * FROM `tagharrypotter` ORDER BY `id` DESC limit 20") or die (mysql_error());
$i = 0;
while($chat = mysql_fetch_assoc($chat1)) {
$mensaje = htmlspecialchars($chat['mensaje']);
//BBCode Nergita
$mensaje = eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<b>\\1</b>", $mensaje);
//BBCode Cursiva
$mensaje = eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<i>\\1</i>", $mensaje);
//BBCode Subrayada
$mensaje = eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>", $mensaje);
//BBCode tachada
$mensaje = eregi_replace("\\[s\\]([^\\[]*)\\[/s\\]","<s>\\1</s>", $mensaje);
if ($i % 2 == 0)
$css = 2;
else
$css = 1;
$i++;
?>

<div class="chatmsj<?=$css;?>">
<b><a href="/perfil/<?=htmlspecialchars($chat['de']);?>"><?=htmlspecialchars($chat['de']);?></a>:</b> <?=$mensaje;?> <?php if($_SESSION['rol'] == "3" or $_SESSION['rol'] == "7" or $_SESSION['rol'] == "19"){echo'[<a href="/virtual/sala-harry-potter/index.php?borrar='.$chat['id'].'">x</a>]'; }?>
</div>
<?php
}
?>

A ver si lo podemos sacar entre todos.