Buenas
tengo un archivo que hace una conexion con la base de datos cada vez que hay algo nuevo me lo muestra en seguida en la web pero al ponerlo donde lo quiero usar me aparecen 2 veces la imagen donde estan los comentarios y en este div donde muestra los comentarios me los muestra encima de la imagen, os dejo una imagen para que se vea mejor.
http://redsocial.16mb.com/Dibujo.bmp
esto lo hace este archivo:
Código PHP:
Ver originalvar xmlhttp = function()
* * {
* * * * var a;try{a = new XMLHttpRequest();}
* * * * catch(e){try{a = new ActiveXObject('Msxml2.XMLHTTP');}
* * * * catch(e){try{a = new ActiveXObject('Microsoft.XMLHTTP');}
* * * * catch(e){alert('Your browser doesn\'t support ajax');a=false;}
* * * * }}return a;
* * };*
* * window.onload = function()
* * {
* * * * var a = new comet();
* * };*
* * var comet = function()
* * {
* * * * var a = new xmlhttp();
* * * * a.open('post',window.location+"?"+Math.random()+"="+Math.random(), true);
* * * * a.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
* * * * a.onreadystatechange = function()
* * * * {
* * * * * * if(a.readyState == 4)
* * * * * * {
* * * * * * * * document.getElementById('content1').innerHTML = a.responseText;
* * * * * * * * window.setTimeout(function(){
* * * * * * * * * * a = new comet();* * * * * * * * * *
* * * * * * * * },1000);
* * * * * * * *
* * * * * * }
* * * * };
* * * * a.send('algo=algo');* * * * * * * *
* * };
Tengo algo mal o porque me produce estos errores??
este es el archivo galeria:
Código PHP:
Ver original<?php
include("header.php");
if (!isset($_SESSION['logueado_usuario'])) { include ("login.php");
}
else {
$nombre =$_SESSION['logueado_nombre'];
$id_usuario=$_SESSION['logueado_id'];
$obejeto=$_REQUEST['objeto'];
}
include("privados/config.php");
$id=$_GET['id'];
$resultados=mysql_query("select * from imagenes where id='$id' and id_logueado='$id_usuario'",$conexion) or
// obtengo el id de la notiica actual
$id = $_GET['id'];
// Obtengo el id de la noticia anterior
$a = mysql_query("select max(id) from imagenes where id <".$id. " and id_logueado='$id_usuario'"); // Obtengo el id de la noticia siguietne
$b = mysql_query("select min(id) from imagenes where id >".$id. " and id_logueado='$id_usuario'"); $a1 = mysql_query("select max(id) from imagenes where id_logueado='$id_usuario'"); // Obtengo el id de la noticia siguietne
$b1 = mysql_query("select min(id) from imagenes where id_logueado='$id_usuario'"); // coloco los links
?><div align="center"><div align="right" id="pasar"><?php
if($idb1!=""){
echo "<a href=galeria.php?id=".$idb1."><img src='Img/primera.png'></a>";}
if($ida!="")
{
echo "<a href=galeria.php?id=".$ida."><img src='Img/atras.png'></a>";
}
if($idb!="")
{
echo "<a href=galeria.php?id=".$idb."><img src='Img/siguiente.png'></a>";
}
if($ida1!=""){
echo "<a href=galeria.php?id=".$ida1."><img src='Img/ultimo.png'></a>";}
?></div><?php
$comentarios=mysql_query("select * from comentario where id_foto='$id'",$conexion); {
$comentario=$comen['comentario'];
}
{
$foto_nombre=$fot['nombre'];
$titulo=$fot['titulo'];
$fecha=$fot['fecha'];
{
echo '<a href=galeria.php?id='.$idb.' title="siguiente"><img src="'.$foto_nombre.'"></a>';
echo '<br>';
echo $comentario;
}
else
{
echo '<img src="'.$foto_nombre.'">';
echo '<br>';
echo $comentario;
}
}
echo "<br>";
?><div align="right" id="pasar" style="margin-top:-49%"><?php echo $fecha."<br>"; echo $titulo; ?></div><?php
?>
<?php
if($_POST)
{
header("Edge-control: no-store"); $notificaciones2=mysql_query("select * from comentario",$conexion); {
echo $rs['comentario']."<br>";
}
}
?>
<script type="text/javascript">
function sapeartextarea(){
var nav=(document.all)?"%0D":"%0A"
var ref=document.getElementById("textarea")
textoarea=escape(ref.value)
lineas=textoarea.split(nav)
lin=lineas.length
if(lin>4){
ref.rows=lin
document.getElementById("clin").innerHTML=lin
}
}
document.onkeyup = function(){sapeartextarea()}
</script>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js'></script>
<script src='js/jquery.autosize.js'></script>
<script>
$(function(){
$('textarea').autosize();
});
</script>
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
<html>
<head>
</head>
<body>
<form name="comentarios" action="" method="post" onSubmit="enviarDatos(); return false">
<input type="hidden" name="id_logueado" value="1">
<input type="hidden" name="id_foto" value="1">
<textarea rows="1" style="overflow:auto;" name="comenta"></textarea>
<input type="submit" name="Submit" value="Grabar" />
</form>
<div id="content1"></div>
<script type="text/javascript" src="js/comet.js"></script>
</body>
</html>
<br /></div>
Necesito alguna idea para poder repararlo, ya que antes de poner ese archivo todo funcionaba bien, gracias. un saludo.