Ver Mensaje Individual
  #35 (permalink)  
Antiguo 18/11/2009, 13:09
Avatar de Distriker
Distriker
 
Fecha de Ingreso: marzo-2008
Ubicación: Las Palmas De Gran Canarias
Mensajes: 924
Antigüedad: 17 años
Puntos: 23
Respuesta: Not a valid MySQL result resource y fallo en una linea 3 pero no lo identi

Hay dios mio me estoy volviendo mas loco de lo que estoy. A ver, ya no se que mostraros, mira, aquí os muestro todos los archivos:

agregar.php

Código PHP:
<?php
require ('configuracion.php') ;
$autor $_POST ["autor"] ;
$titulo $_POST ["titulo"] ;
$mensaje $_POST ["mensaje"] ;
$identificador $_POST ["identificador"] ;

if (
$autor == "" or $titulo == "" or $mensaje == "") {
  echo 
'Complete el formulario' ;
}

$sql "INSERT INTO foro (autor, titulo, mensaje, identificador, fecha, ultimarespuesta) " ;
$sql.= "VALUES ('$autor', '$titulo', '$mensaje', '$identificador', NOW(),NOW())" ;
$rs mysql_query ($sql$conectar) or die("Error al grabar el mensaje: ".mysql_error) ;
$ult_id mysql_insert_id ($conectar) ;

if (!empty(
$identificador))
{
$sql "UPDATE foro SET respuestas=respuestas+1, ultimarespuesta=NOW()" ;
$sql.= " WHERE id = '$identificador'" ;
$rs mysql_query ($conectar$sql) ;
Header ("Location: foro.php?id=$identificador#ult_id") ;
exit () ;
}
Header ("Location index.php") ;
?>
configuracion.php

Código PHP:
<?php
$bdhost 
"localhost" ;
$bduser "****" ;
$bdpass "****" ;
$bd "foro" ;

$conectar mysql_connect ($bdhost$bduser$bdpass$bd) ;
mysql_select_db ($bd$conectar) ;
?>
footer.html

Código HTML:
<div width="90%" border="0" bgcolor="#4b557d">
<center>Foro de soporte de IMGBeta - Diseñador por Distriker <br />
Copyright © IMGBeta <br />
Agradecimientos</center>
</div>
</body>
</html> 
foro.php

Código PHP:
<?php
require ('configuracion.php') ;
require (
'funciones.php') ;
$id $_GET ["id"] ;
if (empty(
$id)) HEader ("Location: index.php") ;

$sql "SELECT id, autor, titulo, mensaje, " ;
$sql.= "DATE_FORMAT(fecha, '%d/%m/%Y %H:%i:%s') as enviado FROM foro " ;
$sql.= "WHERE id='$id' OR identificador='$id' ORDER BY fecha ASC " ;
$rs mysql_query ($conectar$sql) ;
require (
'header.html') ;
if (
mysql_num_rows($rs)>0)
{
require (
'titulos_post.html') ;
$template implode (""file ('post.html')) ;
while (
$row mysql_fetch_assoc ($rs))
{
$color = ($color== ""?"#5b69a6":"") ;
$row ["color" $color ;
$row ["mensaje"] = nl2br ($row["mensaje"]) ;
$row ["mensaje"] = parsearTags($row["mensaje"]) ;
mostrartemplate ($template$row) ;
}
}
require (
'footer.html') ;
?>
funciones.php

Código PHP:
<?php
function mostrartemplate($tema$variables)

{

    
extract($variables);

    eval(
"?>$tema");

}



function 
parsearTags($mensaje)

{

    
$mensaje str_replace("[citar]""<blockquote><hr width='100%' size='2'>"$mensaje);

    
$mensaje str_replace("[/citar]""<hr width='100%' size='2'></blockquote>"$mensaje);

    return 
$mensaje;

}

?>
header.html

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>El Foro de ZonaPHP</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

</style>

</head>
<body bgcolor="#9999cc" text="#FFFFFF" link="#FFFFFF">
<div width="90%" border="0" align="center">
<div bgcolor="#4b557d"><h2>Foro de soporte de IMGBeta</h2>
<div align="right">[ <a href="index.php">Inicio</a>] - <a href="respuesta.php">Nuevo tema</a> ] </div> </div> 
index.php

Código PHP:
<?php
require ('configuracion.php') ;
require (
'funciones.php') ;
require (
'header.html') ;
$sql "SELECT id, autor, titulo, fecha, respuestas, ultimarespuesta " ;
$sql.= "FROM foro WHERE identificador=0 ORDER BY ultimarespuesta DESC " ;
$rs mysql_query ($sql$conectar) or die(mysql_error()) ;
if(
mysql_num_rows($rs)>0)
{
$template implode (""file("temas.html")) ;
require (
'titulos.html') ;
while (
$row mysql_fetch_assoc($rs)) 
{
$color = ($color == ""?"#999999":"") ;
$row ["color"] = $color ;
mostrartemplate ($template$row) ;
}
}
require (
'footer.html') ;
?>
instalador.sql

Código sql:
Ver original
  1. CREATE TABLE IF NOT EXISTS `foro` (
  2. `id` INT(7) NOT NULL AUTO_INCREMENT,
  3. `creador` VARCHAR(200) NOT NULL DEFAULT '',
  4. `titulo` VARCHAR(200) NOT NULL DEFAULT '',
  5. `mensaje` text NOT NULL,
  6. `fecha` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  7. `respuestas` INT(11) NOT NULL DEFAULT '0',
  8. `identificador` INT(7) NOT NULL DEFAULT '0',
  9. `ultima-respuesta` datetime DEFAULT NULL,
  10. KEY `id` (`id`)
  11. ) TYPE=MyISAM ;

post.html

Código HTML:
<div width="90%" border="0" align="center">
<div bgcolor="<?=$color?>">
<div width="25%">
<b></u><a name="<?php=id?>"><?php echo $autor?></a></u></b><br />
<font size="-2">Enviado el: <?php echo $enviado?></font>
</div>
<div width="100%" border="0">
<b><font size="-1"><?php echo $titulo?></font></b>
<div width="10%" align="right"> [ <a href="respuesta.php?id=<?php=id?>&citar=1">Citar</a> ]</div>
</div>
<hr align="center" width="100%" size="2" noshade>
<div>
<?php echo $mensaje?>
</div> 
respuesta.php

Código PHP:
<?php
require ('funciones.php') ;
$id $_GET ["id"] ;
$citar $_GET ["citar"] ;
$row = array ("id" => $id) ;
if (
$citar==1)
{
require (
'configuracion.php') ;
$sql "SELECT titulo, mensaje, identificador AS id WHERE id='$id'";
$rs mysql_query ($conectar$sql) ;
if (
mysql_num_rows($rs)==1$row mysql_fetch_assoc($rs) ;
$row ["titulo"] = "Re: ".$row["titulo"] ;
$row ["mensaje"] = "[citar]".$row ["mensaje"]."[/citar]" ;
if (
$row ["id"]==0$row ["id"] = $id ;
}
$template implode (""file ('formulario.html')) ;
require (
'header.html') ;
mostrartemplate ($template$row) ;
require (
'footer.html') ;
?>
temas.html

Código HTML:
<div width="90%" border="0" align="center" bgcolor="<?php=$color?>">

    <div><a href="foro.php?id=<?=$id?>">

      <?php=$titulo?>

      </a></div>

    <div width="15%" align="center"><font size="-2">Por <b> 

      <?php=$autor?>

      </b><br>

      el 

      <?php=$fecha?>

      </font></div>

    <div width="15%" align="center"><font size="-2"> 

      <?php=$respuestas?>

      </font></div>

    <div width="15%" align="center"><font size="-2"> 

      <?php=$ultima-respuesta?>

      </font></div>

</div>
</div> 
titulos.html

Código HTML:
<div width="90%" border="0" align="center" bgcolor="#4b557d">

<div> 

    <div><a href="foro.php?id=<?=$id?>"> T&iacute;tulo</a></div>

    <div width="15%" align="center">Autor</div>

    <div width="15%" align="center"> Respuestas</div>

    <div width="15%" align="center"> &Uacute;lt. Mensaje</div>

  </div>

</div> 
titulos_post.html

Código HTML:
<div width="90%" border="0" align="center" bgcolor="#4b557d">

  <div align="center"> 

    <div width="25%">Usuario</div>

    <div>Mensaje</div>

  </div>

</div> 
Bueno, esto es todo, ¿qué pensais?

Saludos
__________________
Si no te quejas, nunca conseguiras nada, pero si te quejas siempre lo perderás todo.
Una mala acción da fruto a un mal Karma.