PHP - Notice: Undefined index:

 
Vista:
Imágen de perfil de Angel

Notice: Undefined index:

Publicado por Angel (20 intervenciones) el 16/06/2015 06:25:01
hola a todos necesito su ayuda estoy tratando de hacer un programa pero me genera un error que dice Notice: Undefined index: seleccion in C:\wamp\www\UVIS\MDR\b_voluntarios.php on line 45 al enviar una variable a traves del metodo post este es el codigo en este codigo tengo dos radio button con el nombre seleccion donde cada uno realiza una consulta de busqueda segun el value que seleccione 1 o 2 si escojo la 1 debe realizarme la primera consulta caso contrario la segunda..


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
if (isset($_POST['txt_caja'])) {
  $colname_rsvoluntarios = $_POST['txt_caja'];
}
mysql_select_db($db, $cn);
if($_POST['seleccion']==1) este es la linea 45 la que me genera el error
 
{
 
//consulta 1
$query_rsvoluntarios = sprintf("SELECT ID_CARRERA, ID_FACULTAD, NOMBRE_CARRERA FROM carrera WHERE ID_FACULTAD=%s ORDER BY NOMBRE_CARRERA ASC", GetSQLValueString($colname_rsvoluntarios, "text"));
}
else
{
//consulta 2
$query_rsvoluntarios = sprintf("SELECT ID_CARRERA, ID_FACULTAD, NOMBRE_CARRERA FROM carrera WHERE NOMBRE_CARRERA LIKE %s ORDER BY NOMBRE_CARRERA ASC", GetSQLValueString("%" . $colname_rsvoluntarios . "%", "text"));
}
$rsvoluntarios = mysql_query($query_rsvoluntarios, $cn) or die(mysql_error());
$row_rsvoluntarios = mysql_fetch_assoc($rsvoluntarios);
$totalRows_rsvoluntarios = mysql_num_rows($rsvoluntarios);
 
 
?>
<!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>
<link href="../css/estilos4.css" rel="stylesheet" type="text/css" />
<script src="../SpryAssets/SpryEffects.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_effectGrowShrink(targetElement, duration, from, to, toggle, referHeight, growFromCenter)
{
  Spry.Effect.DoGrow(targetElement, {duration: duration, from: from, to: to, toggle: toggle, referHeight: referHeight, growCenter: growFromCenter});
}
//-->
</script>
</head>

<body onload="MM_effectGrowShrink('form1', 1000, '0%', '100%', false, false, true)">
<form id="form1" name="form1" method="post" action="">
  <table width="415" border="0" align="center" class="tabla">
    <tr>
      <td colspan="2" class="titulo">Busqueda de Voluntarios</td>
    </tr>
    <tr>
      <td width="107"><table width="107">
        <tr>
          <td width="99"><label>
            <input type="radio" name="seleccion" value="1" id="seleccion_0" />
            Cédula</label></td>
        </tr>
        <tr>
          <td><label>
            <input type="radio" name="seleccion" value="2" id="seleccion_1" />
            Apellidos</label></td>
        </tr>
      </table></td>
      <td width="300"><label>
        <input name="txt_caja" type="text" id="txt_caja" size="50" maxlength="50" />
      </label></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><label>
        <input name="btn_buscar" type="submit" class="botones" id="btn_buscar" value="Buscar" />
      </label></td>
    </tr>
  </table>
  <table width="700" border="0" align="center" class="tabla">
    <tr>
      <td colspan="4" class="titulo">Listado de Voluntarios</td>
    </tr>
    <tr>
      <td>Cedula</td>
      <td>Apellidos</td>
    </tr>
espero que me haya hecho entender y me puedad ayuda gracias de antemano.
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
sin imagen de perfil
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Notice: Undefined index:

Publicado por zendi (1056 intervenciones) el 20/06/2015 02:20:15
hola. coloca esta linea de codigo
1
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);

puede ser despues de esta linea

$totalRows_rsvoluntarios = mysql_num_rows($rsvoluntarios);
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);


y me avisas si te sirvio.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
Imágen de perfil de Angel

Notice: Undefined index:

Publicado por Angel (20 intervenciones) el 21/06/2015 22:07:13
Gracias muchas gracias zendi es lo que buscaba me ayudo mucho solo con unpequño detalle que no era en esa linea si no en esta;
if (isset($_POST['txt_caja'])) {
$colname_rsvoluntarios = $_POST['txt_caja'];
}
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);

mysql_select_db($db, $cn);
if($_POST['seleccion']==1)

muchas gracias esperoq puedas seguir ayudando a mas personas como yo
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
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

Notice: Undefined index:

Publicado por xve (6935 intervenciones) el 22/06/2015 08:14:52
Te aconsejo que el error_reporting(), lo pongas en las primeras lineas del código PHP... ya que no tendrás problemas de confusión... si mañana modificas un código de una linea superior, puedes volver a tener algún Noticie o Warning.

Otra manera de solucionarlo, seria revisando si existe el indice creado....

1
if(isset($_POST['seleccion']) && $_POST['seleccion']==1)
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
Imágen de perfil de Angel

Notice: Undefined index:

Publicado por Angel (20 intervenciones) el 23/06/2015 03:43:20
Gracias por tu sugerencia de poner el error_reporting al cominezo del php la voy a probar, la segunda opcion si la probe anteriormente pero no funciono igual me generaba error.
Gracias de todas formas,,me ayudaron mucho
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
Imágen de perfil de Angel

Notice: Undefined index:

Publicado por Angel (20 intervenciones) el 03/11/2015 04:25:35
sa
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
Imágen de perfil de Angel

Notice: Undefined index:

Publicado por Angel (20 intervenciones) el 03/11/2015 04:49:03
sa
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