Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Temas - snake07n

Páginas: [1]
1
Hola a todos...no logro modificar los campos de mi base de datos con la sentencia SQL UPDATE, me da error... Posibles causas?

He adjuntado 2 paginas creadas para que veáis el procedimiento que he seguido... si alguien puede identificar el error,  házmelo saber...
Estoy en fase de aprendizaje y aun no logro tener la suficiente experiencia para identificar el problema...
Mil gracias por vuestro tiempo..

Pagina 1
Código: [Seleccionar]
<?php
$conexion
mysqli_connect("localhost: 3306""root""""taxicorp")or die("Error en la conexion con la BD");
?>


<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>Modificar datos</title>
   
   <style>
      @font-face{
         font-family: 'RobotoMono';
         src: url(Tipografias/RobotoMono.ttf);
         font-style: normal;
      }
     
      table{
         width: 765px; height: 20px;
            border: ridge thick aliceblue;
         background-color: antiquewhite;
         table-layout: inherit;
      }
      #estatic{
         position: absolute;
         left: 185px; top: 85px;
      }
   </style>
   
</head>
<body bgcolor="#000000">
   
   <div id="estatic">
      <form action="mod_dat_tax2.php" method="post">
         <table border="1">
            <tr>
               <td><b>*</b></td>
               <td><b>Matricula</b></td>
               <td><b>Modelo</b></td>
               <td><b>Conductor</b></td>
            </tr>
   <?php
      $sel
"SELECT * FROM taxis";
      
$execmysqli_query($conexion$sel);
            
      while(
$datosmysqli_fetch_row($exec)){
   
?>

            <tr>
                    <td><input type="radio" name="taxi_radio" value="<?php echo($datos[0]);?>"></td>
               <td><?php echo($datos[0]);?></td>
               <td><?php echo($datos[1]);?></td>
               <td><?php echo($datos[2]." ".$datos[3]);?></td>
            </tr>
   <?php
      
}
   
?>

            <tr>
               <td colspan="4" align="center">
               <input type="submit" name="botonEnviar" value="Modificar Datos"></td>
            </tr>
         </table>
      </form>
      <a href="contenido.php" style="float: right; font: 14px bold RobotoMono; color: aliceblue">Volver</a>
   </div>
</body>
</html>
Pagina 2
Código: [Seleccionar]
<?php
$conexion
mysqli_connect("localhost: 3306""root""""taxicorp")or die("Uppsss!!... ALgo ha ido mal...");
?>


<!doctype html>
<html>
<head>
   <meta charset="utf-8">
   <title>Modificar datos</title>
</head>
   <style>
      @font-face{
         font-family: 'RobotoMono';
         src: url(Tipografias/RobotoMono.ttf);
         font-style: normal;
      }
     
      table{
         width: 765px; height: 20px;
         border: ridge thick aliceblue;
         background-color: antiquewhite;
         table-layout: inherit;
      }
      #estatic{
         position: absolute;
         left: 185px; top: 85px;
      }
      h3{
         color: aliceblue;
      }
   </style>
   
<body bgcolor="#000000">
   
    <?php
    
if(!isset($_POST['boton_enviar'])){
        
        
$conexionmysqli_connect("localhost: 3306""root""""taxicorp")or die("Uppsss!!... ALgo ha ido mal...");
        
$sql="SELECT * FROM taxis WHERE Matricula='".$_POST['taxi_radio']."'";
        
$execmysqli_query($conexion$sql);
        
$registromysqli_fetch_row($exec);
    
?>

   <div id="estatic">
   <form action="mod_dat_tax2.php" method="post">
      <table border="1">
         <tr>
            <td colspan="2" align="center"><b>Matricula:&nbsp;<font color="#BB0B0E">
               <?php echo($_POST['taxi_radio']);?></font></b></td>
         </tr>
         <tr>
            <td><b>Modelo:</b></td>
            <td><input type="text" name="Modelo" size="40" value="<?php echo($registro[1]);?>"></td>
         </tr>
         <tr>
            <td><b>Nombre y Apellidos:</b></td>
            <td>
               <input type="text" name="Nombre" value="<?php echo($registro[2]);?>">
               <br>
                <input type="text" name="Apellidos" size="35" value="<?php echo($registro[3]);?>"></td>
         </tr>
         <tr>
            <td><b>Libre:</b></td>
            <td><input type="checkbox" name="libre" <?php if($registro[4]) echo("checked");?>></td>
         </tr>
         <tr>
            <td colspan="2" align="center"><input type="submit" name="boton_enviar" value="Modificar Datos"></td>
         </tr>
      </table>
   </form>
      <a href="mod_dat_tax.php" style="float: right; font: 14px bold RobotoMono; color: aliceblue">Volver</a>
   </div>
   
    <?php
        
    
}else{
      
$update ="UPDATE taxis SET Modelo='".$_POST['Modelo']."',"."Nombre='".$_POST['Nombre']."',";
      
$update.="Apellidos='".$_POST['Apellidos']."',Ocupado=";
      
      if (isset(
$_POST['libre']))
         
$update.="true";
      else
         
$update.="false";
      
        
$update.=" WHERE Matricula='";
        
$update.=$_POST["Modelo"].$_POST["Nombre"].$_POST["Apellidos"]."'";
      
// Sentencia SQL
      
$execmysqli_query($conexion$update);
       
       echo(
"<br>");
      
// Registro en la tabla taxis
      
if(!$exec)
         echo(
"<h3><center>Datos Modificados!!</center></h3>");
      else
         echo(
"<h3><center>Error!!</center></h3>");
        
mysqli_close($conexion);
    }
    
?>


</body>
</html>

Páginas: [1]

Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.

Abraham Lincoln (1808-1865) Presidente estadounidense.

aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación

Preguntas y respuestas

¿Cómo establecer o cambiar la imagen asociada (avatar) de usuario?
  1. Inicia sesión con tu nombre de usuario y contraseña.
  2. Pulsa en perfil --> perfil del foro
  3. Elige la imagen personalizada que quieras usar. Puedes escogerla de una galería de imágenes o subirla desde tu ordenador.
  4. En la parte final de la página pulsa el botón "cambiar perfil".