Foros del Web » Programando para Internet » PHP »

S.O.S. mysql_fetch_assoc(): AYUDA!!!

Estas en el tema de S.O.S. mysql_fetch_assoc(): AYUDA!!! en el foro de PHP en Foros del Web. Saludos tengo un problema al extraer fotos de mi base de datos ... cuando la extraigo me dice esto ............................ Warning: mysql_fetch_assoc(): supplied argument is ...
  #1 (permalink)  
Antiguo 24/01/2008, 13:53
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
S.O.S. mysql_fetch_assoc(): AYUDA!!!

Saludos tengo un problema al extraer fotos de mi base de datos ... cuando la extraigo me dice esto

............................

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Cersol\HTML\list_prod.php on line 33

............................

Aqui les dejo a ver si alguien topa con el error... gracias d antemano
Código PHP:
<?php include('Connections/connect.php');

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

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

$fotos = array();
        
$sql="SELECT  *  FROM productos where pro_id=".$producto_id."  ORDER BY id ASC";
    
$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="257" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="257" height="112"><table width="257" height="112" 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)){ //linea34
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $row['img'];
                
                echo 
"<td height='80' width='53' border='0' ><a href='verimagen.php?pro_id=".$row['pro_id']."'><img src='images2/".$row['imagen']."' width='400' height='400' 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='257'><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>
  #2 (permalink)  
Antiguo 24/01/2008, 14:01
Avatar de eddwinpaz  
Fecha de Ingreso: noviembre-2007
Ubicación: Merida , Venezuela
Mensajes: 1.066
Antigüedad: 16 años, 5 meses
Puntos: 25
Re: S.O.S. mysql_fetch_assoc(): AYUDA!!!

array mysql_fetch_array ( resource $result [, int $result_type ] )


intenta de esta manera haber , debería de correr sin ningún problema.. saludos algún problema me dices por aquí... o me mandas un mensaje privado para responderte en este POST


Código PHP:

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

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

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

$fotos = array();
        
$sql="SELECT  *  FROM productos where pro_id=".$producto_id."  ORDER BY id ASC";
    
$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="257" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="257" height="112"><table width="257" height="112" 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_array($sql_execMYSQL_ASSOC)){ //linea34
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $row['img'];
                
                echo 
"<td height='80' width='53' border='0' ><a href='verimagen.php?pro_id=".$row['pro_id']."'><img src='images2/".$row['imagen']."' width='400' height='400' 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='257'><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>
  #3 (permalink)  
Antiguo 24/01/2008, 14:05
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: S.O.S. mysql_fetch_assoc(): AYUDA!!!

gracias man...
pero sigue dando lo mismo =(
  #4 (permalink)  
Antiguo 24/01/2008, 14:43
Avatar de eddwinpaz  
Fecha de Ingreso: noviembre-2007
Ubicación: Merida , Venezuela
Mensajes: 1.066
Antigüedad: 16 años, 5 meses
Puntos: 25
Re: S.O.S. mysql_fetch_assoc(): AYUDA!!!

que errror te da ?
  #5 (permalink)  
Antiguo 24/01/2008, 15:21
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: S.O.S. mysql_fetch_assoc(): AYUDA!!!

Haz esto:
Código PHP:
$sql_exec=mysql_query($sql) or die( "Query error: $sql mysql:" mysql_error() ); 
y compartenos que error te indica.

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 11:02.