Foros del Web » Programando para Internet » PHP »

switch 'fucking' case

Estas en el tema de switch 'fucking' case en el foro de PHP en Foros del Web. Hola. Stoopid question: Cuantos 'case' puedo tener en un switch? Dig esto porque al sobrepasar los dos case (más el bendito 'default') me da un ...
  #1 (permalink)  
Antiguo 29/07/2002, 03:11
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
switch 'fucking' case

Hola.
Stoopid question:
Cuantos 'case' puedo tener en un switch?
Dig esto porque al sobrepasar los dos case (más el bendito 'default') me da un error:
Código:
Parse error: parse error, unexpected T_CASE in /inlander/sites/parejasliberales-com/web/htdocs/guest/admin/process.php on line 209
Y bueno, en caso que sean solo tres, que puedo usar?

Mi actual código es este:
<a href='ir.asp?http://www.parejasliberales.com/guest/fuckingselect.txt' target='_blank'>http://www.parejasliberales.com/guest/fu...</a>

Y cuando elimino dos select (aceptodas &amp; editar) funciona perfect.

Gracias por adelantado!



<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #2 (permalink)  
Antiguo 29/07/2002, 03:37
Avatar de Cain  
Fecha de Ingreso: enero-2002
Ubicación: Catalunya
Mensajes: 6.459
Antigüedad: 22 años, 3 meses
Puntos: 17
Re: switch 'fucking' case

Puedes usar más de tres case, yo he llegado a usar 15 case diferentes para un mismo switch. Tienes que verificar que todos los case tengan nombres diferentes y que estén bien delimitados { }.

Joe Tawers,
<a href="http://www.ilimit.com/towers">http://www.ilimit.com/towers</a>
  #3 (permalink)  
Antiguo 29/07/2002, 03:51
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

Bien delimitados???

En todas las sintaxis que he visto, no existen tales {} en los case! existe en el switch:
Código:
switch($var) {  
      case &quot;hola&quot;:
            blah blah...

  }  
<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #4 (permalink)  
Antiguo 29/07/2002, 03:52
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

Acá: <a href='ir.asp?http://php.unam.mx/manual/es/control-structures.switch.php' target='_blank'>http://php.unam.mx/manual/es/control-str...</a>

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #5 (permalink)  
Antiguo 29/07/2002, 03:56
Avatar de Cain  
Fecha de Ingreso: enero-2002
Ubicación: Catalunya
Mensajes: 6.459
Antigüedad: 22 años, 3 meses
Puntos: 17
Re: switch 'fucking' case

Es verdad, no usan { }
La estructura es:
Código:
switch ($fuseaction) { 
  case &quot;list&quot;;
  include('qry_list.php');
  include('dsp_list.php');
  break; 
  case &quot;edit&quot;;
  include('qry_edit.php');
  include('dsp_edit.php');
  break;
  ...
  default: 
  include('qry_list.php');
  include('dsp_list.php');
  break; 
}
Joe Tawers,
<a href="http://www.ilimit.com/towers">http://www.ilimit.com/towers</a>
  #6 (permalink)  
Antiguo 29/07/2002, 03:59
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

Exacto! así la tengo.

Y no funciona con más de 3.

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #7 (permalink)  
Antiguo 29/07/2002, 08:13
Nok
 
Fecha de Ingreso: abril-2001
Mensajes: 302
Antigüedad: 23 años
Puntos: 0
Re: switch 'fucking' case

Bueno, luego de mirar un poco tu codigo descubri el siguiente error:

Código:
 
case &quot;aceptodas&quot;:
if (count($del) &gt; 1) {  
  for ($i=0;$i&lt;count($del);$i++) { 
    $result[$i] = mysql_query(&quot;DELETE FROM espera WHERE id = '$del[$i]'&quot;); 
  }

break;
O sea haz abieto una llave y no la haz cerrado por eso, no te encuentra el proximo T_CASE, es un error de sintaxis. Creo que no hay limite para utilizar el &quot;case&quot;.

Es recomendable, cuando estas mucho tiempo con un problema similar, que salgas, te des una vuelta, juegues al futbol, mires tele, y despues mas relajado mira tu codigo y seguro que encuentras el error enseguida ;)

Saludos!

<img name="Firma" src="http://www.jpw.com.ar/FirmaNok.gif" border="0" usemap="#Mapa"><map name="Mapa"><area shape="rect" coords="0,43,174,60" href="http://www.jpw.com.ar/noktemplate"></map>
  #8 (permalink)  
Antiguo 29/07/2002, 08:17
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

Ya lo hice, créeme! ando de un ebrio que ni te cuento!

Eso no funciona, ya que aún quitando todo el select sigue el error.

El error no es la sintaxis de los 'contenidos' de los select.

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #9 (permalink)  
Antiguo 29/07/2002, 08:51
Avatar de Cain  
Fecha de Ingreso: enero-2002
Ubicación: Catalunya
Mensajes: 6.459
Antigüedad: 22 años, 3 meses
Puntos: 17
Re: switch 'fucking' case

Verifica bien todo tu código porque ya te digo que tengo un switch con más de 15 cases diferentes.

Joe Tawers,
<a href="http://www.ilimit.com/towers">http://www.ilimit.com/towers</a>
  #10 (permalink)  
Antiguo 29/07/2002, 09:06
Avatar de gomo  
Fecha de Ingreso: mayo-2002
Ubicación: [email protected]
Mensajes: 906
Antigüedad: 21 años, 11 meses
Puntos: 0
Re: switch 'fucking' case

wakkos lo que dice nok no tiene que ver con la sintaxis del select
Si te fijas en el bloque de codigo que pasteo en su mensaje abris dos llaves { y solo cerras una.
Miralo bien.
Por lo demas yo cuando me saco porque no me funciona un script me vengo a dar una vuelta por los foros :P
Saludos ;)


<div align="center"><img src="http://cablemodem.fibertel.com.ar/sainztrapaga/images/firma.jpg" width="435" height="70" border="0">
</div>
  #11 (permalink)  
Antiguo 29/07/2002, 10:25
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

Lo que respondí arriba:

Ya probé arreglar las llaves, acomodé el código dentro de los select, phasta quité dos select, pero quite los que quite o ponga los que ponga, no pueden ser más de 3!

El problema está en las sintaxis de los select, al menos no está en esas llaves....

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #12 (permalink)  
Antiguo 29/07/2002, 10:30
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

De acuerdo: cambié el código:
Código:
   switch($var) {
   			case &quot;borrar&quot;:
   						echo $var;
					break
						
			case &quot;aceptar&quot;:
						echo $var;
					break
						
			case &quot;editar&quot;:
					echo $var;
					break;
					
					
			case &quot;aceptodas&quot;:
					echo $var;
					break;
			
			default:
					echo &quot;huh?&quot;;
					break;
			
		}

Dudo ahora que el problema está en el código dentro de los select.
Y el mensaje sigue siendo el mimso (al igual que el problema):
&quot;Parse error: parse error, unexpected T_CASE in /inlander/sites/parejasliberales-com/web/htdocs/guest/admin/process.php on line 208&quot;

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
  #13 (permalink)  
Antiguo 29/07/2002, 10:42
Avatar de Wakkos
Colaborador
 
Fecha de Ingreso: octubre-2001
Ubicación: (cerca)
Mensajes: 1.795
Antigüedad: 22 años, 6 meses
Puntos: 59
Re: switch 'fucking' case

*Wakkos entra en la habitación*
*Wakkos te golpea la cabeza contra la pared*

Cuando aprenderás?????

Bueno, el error no estaba en el segundo select.
El error del código posteado arriba está en los puntos y comas luego de los 'break;'

Y el error anterior estaba en un while doinde efectivamente, no se cerraban las llaves.

A veces se debe tomar más cerveza para aclarar la mente!

<div style="color:#000; font-family: Verdana; font-size: 10px; font-weight:bold;">Wakkos<br><a href="http://www.artreves.com/wakk" style="font-size: 9px; font-weight: normal; color:#e1470b;">follow the white rabbit</a></div>
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 02:21.