Foros del Web » Programando para Internet » PHP »

Notice: Undefined variable:

Estas en el tema de Notice: Undefined variable: en el foro de PHP en Foros del Web. Me salio un error, estoy apenas iniciando en PHP y me salio éste " Notice: Undefined variable: consulta in C:\wamp\www\tienda\principal.php on line 39" ¿Podrían ayudarme? ...
  #1 (permalink)  
Antiguo 19/06/2013, 09:08
Avatar de Kanuto1272  
Fecha de Ingreso: octubre-2010
Ubicación: Mexico DF
Mensajes: 21
Antigüedad: 13 años, 6 meses
Puntos: 0
Pregunta Notice: Undefined variable:

Me salio un error, estoy apenas iniciando en PHP y me salio éste " Notice: Undefined variable: consulta in C:\wamp\www\tienda\principal.php on line 39"
¿Podrían ayudarme?
Código:
<?php include('conexion.php') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="200" border="1">
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>BUSCAR:</td>
      <td><label for="buscar"></label>
      <input type="text" name="buscar" id="buscar" /></td>
      <td><input type="submit" name="aceptar" id="aceptar" value="Aceptar" /></td>
    </tr>
    <tr>
      <td colspan="8" align="center">LISTADO DE PRODUCTOS</td>
    </tr>
    <tr>
      <td bgcolor="#FFCC00">ID</td>
      <td bgcolor="#FFCC00">IMAGEN</td>
      <td bgcolor="#FFCC00">NOMBRE</td>
      <td bgcolor="#FFCC00">DESCRIPCION</td>
      <td bgcolor="#FFCC00">PRECIO</td>
      <td bgcolor="#FFCC00">ENSTOCK</td>
      <td bgcolor="#FFCC00">FECHA</td>
      <td bgcolor="#FFCC00">AGREGAR</td>
    </tr>
<?php 
	$conexion=mysql_query('select * from productos');
	while($filas=mysql_fetch_array($consulta)){              <----el error es aquí 
		$id=$filas['id'];
		$imagen=$filas['imagen'];
		$nombre=$filas['nombre'];
		$desc=$filas['descripcion'];
		$precio=$filas['precio'];
		$enStock=$filas['cuanto_hay'];
		$fecha=$filas['fecha'];
	
?>
    
    <tr>
      <td><?php echo $id ?></td>
      <td><img src="<?php echo $imagen; ?>" width="180" height="214"> <br></td>
      <td><?php echo $nombre ?></td>
      <td><?php echo $desc ?></td>
      <td><?php echo $precio ?></td>
      <td><?php echo $enStock ?></td>
      <td><?php echo $fecha ?></td>
      <td>&nbsp;</td>
    </tr>
    <?php }?>
  </table>
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 19/06/2013, 09:45
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Notice: Undefined variable:

bueno respondete esto la variable $consulta existe??? no tendrías que poner mas bien $conexion que es donde estas ejecuntando el query??? siempre es bueno revisar bien los errores
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way

Etiquetas: mysql, web+general
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:43.