Foros del Web » Programando para Internet » PHP »

ERROR: Warning: mysql_fetch_assoc():

Estas en el tema de ERROR: Warning: mysql_fetch_assoc(): en el foro de PHP en Foros del Web. Tengo un error en esta página el cual esta medio tedioso pues antes no salia y de un momento a otro empezó a salir... Warning: ...
  #1 (permalink)  
Antiguo 06/02/2008, 09:23
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
ERROR: Warning: mysql_fetch_assoc():

Tengo un error en esta página el cual esta medio tedioso pues antes no salia y de un momento a otro empezó a salir...


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/indexa/public_html/incomed/prod_inc.php on line 35

Código PHP:

<?php include('Connections/incomed.php');

// Variables de Configuración -----------------------------------
// Define el numero de Filas
$n_filas=3;

//***************************************************************
@$cat=$_REQUEST['id'];
//$cat=6;

$fotos = array();
    
$sql="SELECT id,imgprinc FROM productos ORDER BY id ASC";
mysql_select_db ('incomed');
    
$sql_exec=mysql_query($sql);
    
/*while($row=mysql_fetch_assoc($sql_exec)){
            $tottal=mysql_affected_rows(); // Calculo el numero total de itms a listar
            }*/
$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert);

?>
<table width="520" border="0" align="center" cellpadding="0" cellspacing="8">
  <!--DWLayoutTable-->
  <tr>
    <td width="520" height="124"><table width="520" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
        
        <?php
        $a
=0;// Colocando el contador horizontal en 0
        
$i=1;// Colocando el contador vertical en 0
        
$w=0;//Colocando un contador para el mensaje de "No hay articulos en esta acategoria"
        
            
while($row=mysql_fetch_assoc($sql_exec)){
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $row['imgprinc'];
                
                echo 
"<td height='110' width='100' border='5' ><a href='ficha_prod.php?id=".$row['id']."'><img src='images2/".$row['imgprinc']."' width='160' height='139'border='0'/></a>";
            
                
$r=$a;// contador remanente para listar imagenes sin exceso
                
                    
if ($a >= $n_filas) {
                    
$a=0;// reiniciando el contador horizontal
                    
$i=$i+1;// aumentando el contador vertical
                    
echo '</tr>';
                    } 
            if (empty(
$row)) {
        echo
"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='492'><div align='center'>No hay articulos en esta categoria </div></td>
          </tr>
        </table>
        "
;
        break 
1;}
            
            }
            
         echo 
'</td>';
        
?>
        <?php /*if (empty($w)) {
        echo"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='492'><div align='center'>No hay articulos en esta categoria </div></td>
          </tr>
        </table>
        ";
        exit;}
        */
?>
    </table></td></tr>
</table>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 06/02/2008, 09:26
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: ERROR: Warning: mysql_fetch_assoc():

Prueba hacer tu query asi:
Código PHP:
$sql_exec=mysql_query($sql) or die( "error en $sql: " mysql_error() ); 
Para que te indique cual es el error.

Saludos.
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 16:33.