PHP - Undefined index

 
Vista:

Undefined index

Publicado por Matias Andres Gonzalez Guzman (3 intervenciones) el 03/08/2012 17:43:01
bueno partiendo por saludar, tengo el siguiente problema:

Cuanod abro la pagina de php me arroja dos errores:

Notice: Undefined index: boton_busqueda in C:\wamp\www\interfaz_equipos.php on line 8
Notice: Undefined index: campo_busqueda in C:\wamp\www\interfaz_equipos.php on line 8

Entonces queria saber en que estoy fallando, COMO NOTA: LLEVO 3 DIAS APRENDIENDO PHP, POR FAVOR EXPLICARME CON FRUTA HAHAHA.

Aqui mi codigo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
include("conexion.php");
 
$campo_busqueda = isset($_GET['campo_busqueda']) ? $_GET['campo_busqueda'] : null ;
$campo_busqueda = isset($_GET['boton_busqueda']) ? $_GET['boton_busqueda'] : null ;
//************************ FILTRO ***************************
 
if ($_REQUEST["boton_busqueda"]!=="" and $_REQUEST["campo_busqueda"]!="")
{
	if (is_numeric($_REQUEST["campo_busqueda"]))
	$filtro="cod_equipo=". $_REQUEST["campo_busqueda"];
	else
	$filtro="usuario_equipo like '%".$_REQUEST["campo_busqueda"]."%' or modelo_equipo like '%".$_REQUEST["campo_busqueda"]."%'";
 
} else {
	echo "Por favor ingresar un dato";
}
 
$rst_equipo=mysql_query("SELECT * FROM equipos order by cod_equipo",$connectdb);
$num_registros=mysql_num_rows($rst_equipo);
 
if($num_registros==0)
{
	echo "No se han encontrado equipos para mostrar";
	mysql_close($connectdb);
	exit();
}
$mostrar_registros=10;
$pagina=$_GET["num"];
if (is_numeric($pagina))
	$inicio=(($pagina-1)*$mostrar_registros);
else
	$inicio=0;
$rst_equipo=mysql_query("SELECT * FROM equipos order by cod_equipo LIMIT $inicio,$mostrar_registros;",$connectdb);
$paginas=ceil($num_registros/$mostrar_registros);
?>
 
<!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>Listado de equipos</title>
<style type="text/css">
body {
	background-color: #CCC;
}
</style>
<link href="css/style_interfaz_equipo.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body,td,th {
	font-size: 16px;
}
-->
</style></head>
 
<body link="#FF0000" vlink="#FF0000" alink="#FF0000">
 
<div id="header">
 
  <div id="logo_indap">
  	<img src="img/logo_indap_100px.png" width="100" height="90" alt="logo indap" />
  </div>
 
<div id="motor_busqueda">
  <form id="motor_busqueda" name="motor_busqueda" method="get" action="interfaz_equipos.php">
  	<div id="busqueda">Busqueda:</div>
  	<div id="busqueda"><input id="campo_busqueda" name="campo_busqueda" type="text" value="<?php echo $_GET["campo_busqueda"];?>" /></div>
  	<div id="busqueda"><input id="boton_busqueda" name="boton_busqueda" type="submit" value=" Buscar " /></div>
  </form>
</div>
 
</div>
 
<div id="completa">
 
  <div id="titulo">LISTADO DE EQUIPOS</div>
 
  <div id="campos">
	<div id="codigo">CODIGO</div>
    <div id="marca">MARCA</div>
    <div id="modelo">MODELO</div>
    <div id="usuario">USUARIO</div>
  </div>
 
 
  <div id="campos2">
  <table width="1024" border="1" cellpadding="0" cellspacing="0">
 
   <?php
   while ($fila=mysql_fetch_array($rst_equipo))
  {
  ?>
 
  <tr height="20px">
  <td align="left" bordercolor="#000000" style="width: 254px" height="25px"><?php echo $fila["cod_equipo"];?></td>
  <td align="left" bordercolor="#000000" style="width: 254px" height="25px"><?php echo $fila["marca_equipo"];?></td>
  <td align="left" bordercolor="#000000" style="width: 254px" height="25px"><?php echo $fila["modelo_equipo"];?></td>
  <td align="left" bordercolor="#000000" style="width: 254px" height="25px"><?php echo $fila["usuario_equipo"];?></td>
  </tr>
 
  <?php
  }
  ?>
  </table>
 
  <div id="cont_list_paginas">
  	<div id="lista_paginas">
 	 <?php
	 if ($pagina>1)
	 echo "<a href='interfaz_equipos.php?num=".  ($pagina-1)  ."' >Anterior</a> ";
 
  	 for ($cont=1;$cont<=$paginas;$cont++)
  	 {
		if($cont==$pagina)
			echo $cont ." ";
		else
  		echo "<a href='interfaz_equipos.php?num=".  $cont  ."' >$cont</a> ";
	 }
	 if ($pagina<$mostrar_registros)
	 	echo "<a href='interfaz_equipos.php?num=".  ($pagina+1)  ."' >Siguiente</a> ";
  	 ?>
    </div>
  </div>
 
  </div>
 
</div>
<p>&nbsp;</p>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Undefined index

Publicado por xve (6935 intervenciones) el 03/08/2012 18:03:16
Hola Matias, no es un Error, es una Notice. No se donde lo estas ejecutando, pero en el php.ini puedes deshabilitarlo. Hay varios mensajes en los foros de como deshabilitar estos mensajes.

Lo que dice, es que esos índices, no han sido definidos... que no están en el array $_GET...

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Undefined index

Publicado por Matias Andres Gonzalez Guzman (3 intervenciones) el 03/08/2012 19:06:31
me podrias dar un link esque el internet de mi trabajo es una "##"%#%$"# muchas gracias de ante mano :)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar