Foros del Web » Programando para Internet » PHP »

donde esta el fallo? "noticias"

Estas en el tema de donde esta el fallo? "noticias" en el foro de PHP en Foros del Web. Buenas, miren voy a dejarle el codigo de dos paginas.php para que me digan donde hay algun error. Mi objetivo es primeramente un listado de ...
  #1 (permalink)  
Antiguo 19/09/2007, 07:26
 
Fecha de Ingreso: octubre-2006
Mensajes: 137
Antigüedad: 17 años, 6 meses
Puntos: 2
donde esta el fallo? "noticias"

Buenas, miren voy a dejarle el codigo de dos paginas.php para que me digan donde hay algun error. Mi objetivo es primeramente un listado de las 6 noticias ultimas y que cada titulo de la noticia linkee con su id y en el otro archivo.php se dicte la noticia completa.

el index donde se listan las noticias carga bien pero al insertar una noticia desde el phpmyadmin no se refleja luego aqui, sin embargo se inserta correctamente.

en noticias.php me da un error que es:

ERROR: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/aymar/domains/aymar.es/public_html/new/noticias.php on line 24

la linea 24 es exactamente esta :

while ($row2 = mysql_fetch_array ($res2)){

index.php

Código PHP:
<?
    
echo "<table width='123' border='0' align='center' cellpadding='0' cellspacing='2'>
      <tr>
        <td height='10' colspan='2'><img src='images/transparente_presentacion.gif' width='2' height='10' /><img src='images/transparente_presentacion.gif' width='2' height='10' /></td>
        </tr>
        <tr>
        <td height='25' colspan='2' bgcolor='#5C2216'><div align='center' class='tipografia_general_titulos'>Noticias</div></td>
        </tr>"
;
        
        include (
'conexion.php');
        
conectar();
        
$sql "SELECT * FROM noticias Where id_noticias ='".$id." ORDER BY id_noticias LIMIT 1,6 '";
        
$res mysql_query($sql);
        
        while (
$row mysql_fetch_array($res)){
        
        echo 
"<tr>
        <td width='15' bgcolor='#333333'><div align='center'><img src='images/icon-amarillo.gif' width='9' height='9' /></div></td>
        <td width='102' height='18' bgcolor='#333333'><a href='"
.$row['id_noticias']."'>".$row['titulo']."</a></td>
      </tr>
      <tr>
        <td bgcolor='#333333'>&nbsp;</td>
        <td height='18' bgcolor='#333333'>"
;
        function 
fecha(){
        
$mes date("n");
        
$mesArray = array(
        
=> "Enero",
        
=> "Febrero",
        
=> "Marzo",
        
=> "Abril",
        
=> "Mayo",
        
=> "Junio",
        
=> "Julio",
        
=> "Agosto",
        
=> "Septiembre",
        
10 => "Octubre",
        
11 => "Noviembre",
        
12 => "Diciembre"
        
);
        
        
$semana date("D");
        
$semanaArray = array(
        
"Mon" => "Lunes",
        
"Tue" => "Martes",
        
"Wed" => "Miercoles",
        
"Thu" => "Jueves",
        
"Fri" => "Viernes",
        
"Sat" => "Sábado",
        
"Sun" => "Domingo",
        );

$mesReturn $mesArray[$mes];
$semanaReturn $semanaArray[$semana];
$dia date("d");
$año date ("Y");

return 
$semanaReturn." ".$dia." de ".$mesReturn." de ".$año;
}
echo 
fecha();
echo 
"</td>
      </tr>"
;
      }

    echo 
"</table>";
         
?>
noticias.php

Código PHP:
<?
    
include ('conexion.php');
    
conectar();
    
$sql2 "Select * From videos Where id_noticias = '".$_GET['id_noticias']."' ORDER BY id_noticias LIMIT 1";
    
$res2 mysql_query($sql2);
    while (
$row2 mysql_fetch_array ($res2)){ 
    echo 
"<table width='435' border='0' align='center' cellpadding='0' cellspacing='2'>
      <tr>
        <td height='10'><img src='images/transparente_presentacion.gif' width='2' height='10' /></td>
      </tr>
      <tr>
        <td height='25' bgcolor='#5C2216'><div align='center' class='tipografia_general_titulos'>"
.$row2['titulo']."</div></td>
      </tr>
      <tr>
        <td height='102' valign='top' class='tipografia_general'><table width='433' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='281' height='102' valign='top'>"
.$row2['contenido']."</td>
            <td width='150' valign='top'>"
.$row2['foto']."</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td class='tipografia_general'>"
; function fecha(){
        
$mes date("n");
        
$mesArray = array(
        
=> "Enero",
        
=> "Febrero",
        
=> "Marzo",
        
=> "Abril",
        
=> "Mayo",
        
=> "Junio",
        
=> "Julio",
        
=> "Agosto",
        
=> "Septiembre",
        
10 => "Octubre",
        
11 => "Noviembre",
        
12 => "Diciembre"
        
);
        
        
$semana date("D");
        
$semanaArray = array(
        
"Mon" => "Lunes",
        
"Tue" => "Martes",
        
"Wed" => "Miercoles",
        
"Thu" => "Jueves",
        
"Fri" => "Viernes",
        
"Sat" => "Sábado",
        
"Sun" => "Domingo",
        );

$mesReturn $mesArray[$mes];
$semanaReturn $semanaArray[$semana];
$dia date("d");
$año date ("Y");

return 
$semanaReturn." ".$dia." de ".$mesReturn." de ".$año;
}
echo 
fecha();
    echo 
"</td>
      </tr>"
;
      }
    echo 
"</table>";
?>
estoy desesperado, espero me ayuden, un saludo y gracias
  #2 (permalink)  
Antiguo 19/09/2007, 08:07
Avatar de gerson  
Fecha de Ingreso: febrero-2005
Ubicación: Lima
Mensajes: 481
Antigüedad: 19 años, 2 meses
Puntos: 4
Re: donde esta el fallo? "noticias"

Pues tu consulta debe de apuntar a la tabla "noticias" y no a videos; o me equivoco?.

Otra cosa q note en index.php es el uso de las comillas simples, es raro que te funcione:

Código PHP:
 $sql "SELECT * FROM noticias Where id_noticias ='".$id." ORDER BY id_noticias LIMIT 1,6 '"
deberia de ser asi
Código PHP:
 $sql "SELECT * FROM noticias Where id_noticias ='".$id."' ORDER BY id_noticias LIMIT 1,6"
Saludos
__________________

  #3 (permalink)  
Antiguo 19/09/2007, 08:54
 
Fecha de Ingreso: octubre-2006
Mensajes: 137
Antigüedad: 17 años, 6 meses
Puntos: 2
Re: donde esta el fallo? "noticias"

e corregido todo eso y ahora no em da errores pero se queda tanto en el index ,"la zona donde debe aparecer el titulo fecha", como noticias.php ",donde deben listarse", en blanco.

que puede pasar?
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:09.