Foros del Web » Programando para Internet » PHP »

mysql_fetch_assoc():

Estas en el tema de mysql_fetch_assoc(): en el foro de PHP en Foros del Web. Saludos señores, ando diseñando un nuevo sistemita y tengo un problema al marcar la region repetida o hacer el while sale lo siguiente sale el ...
  #1 (permalink)  
Antiguo 25/01/2008, 09:38
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Exclamación mysql_fetch_assoc():

Saludos señores,

ando diseñando un nuevo sistemita y tengo un problema al marcar la region repetida o hacer el while sale lo siguiente
sale el primer articulo q contiene la base de datos seguido de esta nota

Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in C:\wamp\www\Cersol\HTML\prueba.php on line 57

aqui les dejo mi codigo para ver si alguien podria hecharme una manito...
Saludos y gracias!!

Código PHP:
<?php require_once('Connections/connect.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;
}
}

$colname_Recordset1 "-1";
if (isset(
$_GET['cat_id'])) {
  
$colname_Recordset1 $_GET['cat_id'];
}
mysql_select_db($database_connect$connect);
$query_Recordset1 sprintf("SELECT * FROM marca WHERE cat_id = %s ORDER BY marca_id ASC"GetSQLValueString($colname_Recordset1"int"));
$Recordset1 mysql_query($query_Recordset1$connect) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

mysql_free_result($Recordset1);
?>
<?php 
do { ?>
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><img src="images/<?php echo $row_Recordset1['imagen']; ?>" width="130" height="130" border="0" class="bordeimg" /></td>
    </tr>
    
    <tr>
      <td><?php echo $row_Recordset1['nombre']; ?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
      </table>
  <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
  #2 (permalink)  
Antiguo 25/01/2008, 09:48
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años
Puntos: 10
Re: mysql_fetch_assoc(): AYUDA.

Ésta linea va hasta el final del bucle ó en su defecto del script

mysql_free_result($Recordset1);

Código PHP:
<?php do { ?>
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><img src="http://www.forosdelweb.com/images/<?php echo $row_Recordset1['imagen']; ?>" width="130" height="130" border="0" class="bordeimg" /></td>
    </tr>
    
    <tr>
      <td><?php echo $row_Recordset1['nombre']; ?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
      </table>
  <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); 
mysql_free_result($Recordset1);?>
No estaria mal que consultaras en el manual de php más detalles sobre mysql_free_result
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #3 (permalink)  
Antiguo 25/01/2008, 09:49
Avatar de eits  
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 18 años, 9 meses
Puntos: 88
Re: mysql_fetch_assoc(): AYUDA.

y tambien, prueba eliminando esta linea $row_Recordset1 = mysql_fetch_assoc($Recordset1); de aquí

mysql_select_db($database_connect, $connect);
$query_Recordset1 = sprintf("SELECT * FROM marca WHERE cat_id = %s ORDER BY marca_id ASC", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $connect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);<------quita esta linea
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

saludos.
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.
  #4 (permalink)  
Antiguo 25/01/2008, 09:50
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: mysql_fetch_assoc(): AYUDA.

Estas liberando el recordset, antes de tu while, es por eso que ya no puedes descargar mas resultados, necesitas mover el:
Código PHP:
mysql_free_result($Recordset1); 
Hasta el final de tu while.

Saludos.
  #5 (permalink)  
Antiguo 25/01/2008, 10:04
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 7 meses
Puntos: 28
Re: mysql_fetch_assoc(): AYUDA.

gracias man.. efectivamente no estaba liberando resultados... Gracias a todos por su atencion, muy amables :)
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 04:55.