| 
	
		|  Autor | Tema: select case sql, enviar form  (Leído 6,477 veces) |  
	| 
			| 
					
						| alexkof158 
								 
								
								 Desconectado 
								Mensajes: 415
								
								 
								LOL
								
								
								
								
								
								   | 
 
hola lo que pasa es que tengo un formulario donde tengo un select case donde extraigo los datos de la cedula y cargo desde la BD pero al momento de enviar el formulario con los datos precargados me dice error en la bd, espero que me haya dado a explicar,  aki dejo los codigos por si acaso Vista Formulario
 <?Php$servidor = "localhost";
 $usuario_bd = "root";
 $password_bd = "";
 $basedatos = "empresa";
 
 
 $conexion = mysql_connect($servidor,$usuario_bd,$password_bd);
 if (!$conexion)
 {
 echo "Error conectando a la base de datos.";
 exit();
 }
 
 $resultado=mysql_select_db($basedatos,$conexion);
 if (!$resultado)
 {
 echo "Error seleccionando la base de datos.";
 exit();
 }
 ?>
 <!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
 <title>Mantenimientos y Servicios</title>
 <style type="text/css">
 .style2 {
 background-color: #3366CC;
 }
 </style>
 </head>
 <body>
 <div id="layer1" style="position: absolute; width: 459px; height: 427px; z-index: 1; left: 10px; top: 15px; visibility: visible;" class="style2">
 <form method="post" action="mantyserv.php" style="height: 206px">
 
 <h1 align="center">Mantenimiento y Servicios</h1>
 <table style="width: 93%; height: 147px;">
 <tr>
 <td style="width: 148px; height: 45px;">Código</td>
 <td style="height: 45px">
 <select name="sel_vend" id="sel_vend" style="width: 140px">
 <?php
 $cod_ve = array();
 $cod_vn = array();
 // $c = 0;
 $consulta= "SELECT * FROM empleados ";
 $resultado = mysql_query($consulta) or die('La consulta falló: ' . mysql_error());
 
 while($linea = mysql_fetch_array($resultado)){
 
 
 echo " <option value=\"".$linea[0]."\">".$linea[1]."</option>\n";
 
 }
 ?>
 </select> </td>
 </tr>
 <tr>
 <td style="width: 148px; height: 45px;">Tipo de Mantenimiento</td>
 <td style="height: 45px"><select multiple name ="tmant" style="width: 133px">
 <option>Limpieza</option>
 <option>Completo</option>
 <option>Sistema</option>
 <option>Otro</option>
 </select></td>
 
 </tr>
 <tr>
 <td style="width: 148px">Asignar Técnico</td>
 <td>
 <select name="sel_vend" id="sel_vend2" style="width: 133px; height: 18px;">
 <?php
 $cod_ve = array();
 $cod_vn = array();
 // $c = 0;
 $consulta= "SELECT * FROM empleados where cargo='Tecnico'";
 $resultado = mysql_query($consulta) or die('La consulta falló: ' . mysql_error());
 
 while($linea = mysql_fetch_array($resultado)){
 
 
 echo " <option value=\"".$linea[0]."\">".$linea[4]."</option>\n";
 
 }
 ?>
 </select> 
 </td>
 </tr>
 <tr>
 <td style="width: 148px">Valor Asignado $</td>
 <td><input name="valor" style="width: 133px" type="text" /></td>
 </tr>
 
 </table>
 <p>Ingrese sus dudas o Notas</p>
 <textarea name="notes" style="width: 404px; height: 69px"></textarea>
 <input name="Submit1" type="submit" value="Enviar" />
 <input name="Reset1" type="reset" value="Limpiar Campos" />
 </form>
 
 </div>
 
 </body>
 
 </html>
 
Procesar Form
 <?php$conexion=mysql_connect("localhost","root","") or die("ha ocurrido un error en la conexion");
 mysql_select_db("empresa",$conexion) or die("no se ha podido seleccionar la base de datos");
 mysql_query("insert into mantyserv(sel_vend,tmant,sel_vend2,valor,notes) values('$_REQUEST[sel_vend]','$_REQUEST[tmant]','$_REQUEST[sel_vend2]','$_REQUEST[valor]','$_REQUEST[notes]')", $conexion) or die ("error al registrar datos");
 mysql_close();
 echo "<h1>Registro de Datos</h1>";
 printf("volver");
 printf("<a href= inicio.php>Volver al Inicio</a>");
 
 ?>
espero me ayudenn..xd
 
 |  
						| 
								|  |  
								| « Última modificación:  2 Diciembre 2009, 11:00 am por alexkof158 » |  En línea | 
 
 |  |  |  | 
			| 
					
						| alexkof158 
								 
								
								 Desconectado 
								Mensajes: 415
								
								 
								LOL
								
								
								
								
								
								   | 
 
nadie me ayuda   
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| fede_cp 
								 
								
								 Desconectado 
								Mensajes: 527
								
								 
								"porque pensar nunca fue entender"
								
								
								
								
								
								     | 
 
<?Php$servidor = "localhost";$usuario_bd = "root"; $password_bd = ""; $basedatos = "empresa";   if (!$conexion){    echo "Error conectando a la base de datos.";} if (!$resultado){    echo "Error seleccionando la base de datos.";}?><!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 content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Mantenimientos y Servicios</title><style type="text/css">.style2 {	background-color: #3366CC;}</style></head><body><div id="layer1" style="position: absolute; width: 459px; height: 427px; z-index: 1; left: 10px; top: 15px; visibility: visible;" class="style2"><form method="post" action="mantyserv.php" style="height: 206px"> <h1 align="center">Mantenimiento y Servicios</h1>	<table style="width: 93%; height: 147px;">		<tr>			<td style="width: 148px; height: 45px;">Código</td>			<td style="height: 45px">			<select name="sel_vend" id="sel_vend" style="width: 140px">            <?php              // $c = 0;              $consulta= "SELECT * FROM empleados ";                  echo " <option value=\"".$linea[0]."\">".$linea[1]."</option>\n";               }              ?>          </select> </td>		</tr>		<tr>			<td style="width: 148px; height: 45px;">Tipo de Mantenimiento</td>			<td style="height: 45px"><select multiple name ="tmant" style="width: 133px">			<option>Limpieza</option>			<option>Completo</option>			<option>Sistema</option>			<option>Otro</option>			</select></td> 		</tr>		<tr>			<td style="width: 148px">Asignar Técnico</td>			<td>			<select name="sel_vend" id="sel_vend2" style="width: 133px; height: 18px;">            <?php              // $c = 0;              $consulta= "SELECT * FROM empleados where cargo='Tecnico'";                  echo " <option value=\"".$linea[0]."\">".$linea[4]."</option>\n";               }              ?>          </select> </td>		</tr>		<tr>			<td style="width: 148px">Valor Asignado $</td>			<td><input name="valor" style="width: 133px" type="text" /></td>		</tr> 		</table>		<p>Ingrese sus dudas o Notas</p>		<textarea name="notes" style="width: 404px; height: 69px"></textarea>	<input name="Submit1" type="submit" value="Enviar" />	<input name="Reset1" type="reset" value="Limpiar Campos" />	</form> 			</div> </body> </html>
 <?php$conexion=mysql_connect("localhost","root","") or die("ha ocurrido un error en la conexion");mysql_select_db("empresa",$conexion) or die("no se ha podido seleccionar la base de datos");mysql_query("insert into mantyserv(sel_vend,tmant,sel_vend2,valor,notes) values('$_REQUEST[sel_vend]','$_REQUEST[tmant]','$_REQUEST[sel_vend2]','$_REQUEST[valor]','$_REQUEST[notes]')", $conexion) or die ("error al registrar datos");echo "<h1>Registro de Datos</h1>";  printf("<a href= inicio.php>Volver al Inicio</a>"); ?>
 ahi esta mejor el codigo   el error que te dice es el que vos pusiste???, osea "Error conectando a la base de datos". saludos |  
						| 
								|  |  
								|  |  En línea | 
 
 somos lo que hacemos para cambiar lo que somos
 http://elhackerblog.blogspot.com el blog de elhacker.net!!
 |  |  |  | 
			| 
					
						| mokoMonster 
								 
								
								 Desconectado 
								Mensajes: 301
								
								 
								<? ...
								
								
								
								
								
								   | 
 
este codigo esta muy bien hecho xD si pudiera votar por un post seria por este, y otros mas xD hahaha     |  
						| 
								|  |  
								|  |  En línea | 
 
 "Se necesitaron unos instantes para cortarle la cabeza, pero se necesitara un siglo para producir otra igual."Lagrange
 
 |  |  |  | 
			| 
					
						| Syphroot 
								
								 Desconectado 
								Mensajes: 268
								
								 
								All You Need To Do Is Follow The Worms
								
								
								
								
								
								     | 
 
Al parecer es tu segundo SELECT: <select name="sel_vend" id="sel_vend2" style="width: 133px; height: 18px;">
tienes dos con el mismo nombre, y el codigo que procesa tu form espera la variable "sel_vend2", que supuestamente debería ser tu segundo select ( lo supe por el ID que le asignaste a la etiqueta) Saludos! |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| mokoMonster 
								 
								
								 Desconectado 
								Mensajes: 301
								
								 
								<? ...
								
								
								
								
								
								   | 
 
Oh mira que bien  xD      |  
						| 
								|  |  
								|  |  En línea | 
 
 "Se necesitaron unos instantes para cortarle la cabeza, pero se necesitara un siglo para producir otra igual."Lagrange
 
 |  |  |  |  |  
 
	
 
 
				
					
						| Mensajes similares |  
						|  | Asunto | Iniciado por | Respuestas | Vistas | Último mensaje |  
						|   |   | Hacer valores aleatorios sin Select Case Programación Visual Basic
 | oskoa | 7 | 4,425 |  14 Noviembre 2011, 19:28 pm por BlackZeroX
 |  
						|   |   | consejo sobre el uso del Select Case en este ejercicio Programación Visual Basic
 | lio crossroad | 6 | 5,285 |  21 Abril 2013, 22:48 pm por lio crossroad
 |  
						|   |   | [DUDA] Select Case Programación Visual Basic
 | Zodiak98 | 2 | 2,554 |  21 Mayo 2013, 13:24 pm por 79137913
 |  
						|   |   | Ayuda con Select Case VBS Scripting
 | Wartherion | 5 | 3,975 |  12 Junio 2015, 11:28 am por Eleкtro
 |  
						|   |   | Como Puedo Poner Notas En Select Case ? Programación Visual Basic
 | R3Z | 2 | 2,477 |  14 Julio 2015, 16:11 pm por 79137913
 |    |