Foros del Web » Programando para Internet » PHP »

Warning: mysql_fetch_assoc():

Estas en el tema de Warning: mysql_fetch_assoc(): en el foro de PHP en Foros del Web. saludos tengo un include donde extraigo las 3 ultimas noticias de la base de datos y me da este error... Warning: mysql_fetch_assoc(): 4 is not ...
  #1 (permalink)  
Antiguo 05/02/2008, 09:07
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Warning: mysql_fetch_assoc():

saludos tengo un include donde extraigo las 3 ultimas noticias de la base de datos y me da este error...

Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in /home/wwwteam/public_html/prueba/inc_not.php on line 72

Este es el codigo
Código PHP:
<?php require_once('Connections/azimut.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$maxRows_Recordset1 10;
$pageNum_Recordset1 0;
if (isset(
$_GET['pageNum_Recordset1'])) {
  
$pageNum_Recordset1 $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;

mysql_select_db($database_azimut$azimut);
$query_Recordset1 "SELECT * FROM noticias";
$query_limit_Recordset1 sprintf("%s LIMIT %d, %d"$query_Recordset1$startRow_Recordset1$maxRows_Recordset1);
$Recordset1 mysql_query($query_limit_Recordset1$azimut) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);

if (isset(
$_GET['totalRows_Recordset1'])) {
  
$totalRows_Recordset1 $_GET['totalRows_Recordset1'];
} else {
  
$all_Recordset1 mysql_query($query_Recordset1);
  
$totalRows_Recordset1 mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_free_result($Recordset1);
$resumen substr$row_Recordset1['contenido'], 150);

?>
<link href="css/estilos.css" rel="stylesheet" type="text/css">
<?php do { ?>
<table width="387" border="0">
  <tr>
    <td width="11%" rowspan="2" align="center" valign="top"><img src="images2/<?php echo $row_Recordset1['imagen']; ?>" width="60" height="60"></td>
    <td width="89%" class="titulo1"><?php echo $row_Recordset1['titulo']; ?></td>
  </tr>
  <tr>
    <td valign="top" class="link3"><div align="justify"><?php echo $resumen?> ...</div>
    <a href="ficha_not.php?id=<?php echo $row_Recordset1['id']; ?>" class="textoINDEX">Leer m&aacute;s</a></td>
  </tr>
  <tr>
    <td height="25" colspan="2" align="center" valign="top"></td>
  </tr>
</table>
<?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>

<?php
mysql_free_result
($Recordset1);
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 05/02/2008, 09:35
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: Warning: mysql_fetch_assoc():

Tu problema es que estas liberando el resultado de tu consulta, y despues quieres hacer un do/while con esa misma consulta.

Saludos.
  #3 (permalink)  
Antiguo 05/02/2008, 09:46
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: Warning: mysql_fetch_assoc():

q recomiendas??? q libere los datos despues del do/while??
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 05/02/2008, 09:53
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: Warning: mysql_fetch_assoc():

Asi es, porque si no limpias la consulta y no puedes recorrerla.

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 06:55.