Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/01/2015, 12:24
ultrax0880
 
Fecha de Ingreso: enero-2015
Mensajes: 6
Antigüedad: 9 años, 4 meses
Puntos: 0
Respuesta: Problema con Column count doesn't match value count at row 1

tengo una solución dentro del mismo sistema si le doy a una opcion que dice "editar carrera" puedo agregarle el nombre y ya aparecerá en el sistema y la bd ahora hay un problema al querer agregar un grado me sale el siguiente error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '==Seleccione Su Carrera==)' at line 1

Código PHP:
Ver original
  1. <?php
  2. require("conectar.php");
  3. $sel_per = "select * from periodo";
  4.   $eje_per = mysql_query($sel_per);
  5.   $con_per = mysql_num_rows($eje_per);
  6.   $ver_per = mysql_fetch_array($eje_per);
  7.  
  8.   if($ver_per["estado_periodo"] == "Activo")
  9.   {
  10.  
  11. if(isset($_POST["agregar"]))
  12. {
  13. require("conectar.php");
  14. $nombre = $_POST["nombre"];
  15. $carrera = $_POST["carrera"];
  16.  
  17. $inser = "insert into grado values(NULL,'$nombre',$carrera)";
  18.  
  19. if(mysql_query($inser))
  20.     {
  21.         header("location: ver_grado.php");
  22.         exit;
  23.     }
  24. else
  25.     {
  26.         echo mysql_error();
  27.     }
  28. }
  29. else
  30. {
  31. ?>
  32. <style type="text/css">
  33. <!--
  34. .centro {
  35.     text-align: center;
  36.     font-family: "Comic Sans MS";
  37.     font-size: 24px;
  38. }
  39. .letra {
  40.     font-family: "Comic Sans MS";
  41.     text-align: right;
  42. }
  43. -->
  44. </style>
  45. <form name="form1" method="post" action="">
  46.   <table width="700" border="0" align="center">
  47.     <tr>
  48.       <td colspan="2" bgcolor="#0099CC" class="centro">Datos Requeridos</td>
  49.     </tr>
  50.     <tr>
  51.       <td width="344">&nbsp;</td>
  52.       <td width="346">&nbsp;</td>
  53.     </tr>
  54.     <tr>
  55.       <td class="letra">Seleccione Su Carrera:</td>
  56.       <td>
  57.       <?php
  58.         require ("conectar.php");
  59.          
  60.         $sql="select * from carrera";
  61.         $ejecuta=mysql_query($sql);
  62.          
  63.         echo"<select name=carrera onChange='submit();'><option>==Seleccione Su Carrera==";
  64.           if($ejecuta>0)
  65.             {
  66.                   while($todo=mysql_fetch_array($ejecuta))
  67.                   {
  68.                     echo "<option value='$todo[cod_carrera]' " ;
  69.                         if($todo["cod_carrera"]==$carrera)
  70.                             {
  71.                                 echo "selected='selected'";
  72.                             }
  73.         echo ">";
  74.                     echo $todo["nombre_carrera"];
  75.                    
  76.                  }
  77.                  
  78.           echo"</select>";
  79.           echo "<input name=oculto type=hidden value=1>";
  80.           }
  81.           else
  82.           {
  83.           echo mysql_error();
  84.           }
  85.           ?>
  86.           </td>
  87.     </tr>
  88.     <tr>
  89.       <td>&nbsp;</td>
  90.       <td>&nbsp;</td>
  91.     </tr>
  92.   </table>
  93.   <?php
  94.   if($_POST["oculto"]==1)
  95.   {
  96.   ?>
  97.   <table width="700" border="0" align="center">
  98.     <tr>
  99.       <td colspan="2" bgcolor="#99CC66" class="centro">Agregar Grado</td>
  100.     </tr>
  101.     <tr>
  102.       <td width="245">&nbsp;</td>
  103.       <td width="245">&nbsp;</td>
  104.     </tr>
  105.     <tr>
  106.       <td class="letra">Nombre del Grado:</td>
  107.       <td><label>
  108.         <input name="nombre" type="text" id="nombre" size="40">
  109.       </label></td>
  110.     </tr>
  111.     <tr>
  112.       <td>&nbsp;</td>
  113.       <td>&nbsp;</td>
  114.     </tr>
  115.     <tr>
  116.       <td colspan="2" class="centro"><label>
  117.         <input type="submit" name="agregar" id="agregar" value="Agregar Grado">
  118.       </label></td>
  119.     </tr>
  120.   </table>
  121. </form>
  122. <?php
  123.   }
  124. }
  125.   }
  126.   else
  127.   {
  128.           ?>
  129.       <script>
  130.       alert('El Periodo ya esta Cerrado, Abra uno Nuevo');
  131.       </script>
  132.       <?php
  133.   }
  134. ?>



Código SQL:
Ver original
  1. --
  2. -- Estructura de tabla para la tabla `grado`
  3. --
  4.  
  5. CREATE TABLE `grado` (
  6.   `cod_grado` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
  7.   `nombre_grado` VARCHAR(100) NOT NULL,
  8.   `cod_carrera` INT(5) UNSIGNED NOT NULL,
  9.   PRIMARY KEY  (`cod_grado`),
  10.   KEY `cod_carrera` (`cod_carrera`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
  12.  
  13. --
  14. -- Volcar la base de datos para la tabla `grado`
  15. --
  16.  
  17. INSERT INTO `grado` VALUES (1, 'Primero', 1);
  18. INSERT INTO `grado` VALUES (2, 'Segundo', 4);
  19. INSERT INTO `grado` VALUES (3, 'Segundo', 1);
  20. INSERT INTO `grado` VALUES (4, 'Tercero', 1);
  21. INSERT INTO `grado` VALUES (5, 'Tercero', 4);
  22. INSERT INTO `grado` VALUES (6, 'Primero', 4);
  23. INSERT INTO `grado` VALUES (7, 'Primero', 2);
  24. INSERT INTO `grado` VALUES (8, 'Segundo', 2);
  25. INSERT INTO `grado` VALUES (9, 'Tercero', 2);
  26. INSERT INTO `grado` VALUES (10, 'Primero', 3);
  27. INSERT INTO `grado` VALUES (11, 'Segundo', 3);
  28. INSERT INTO `grado` VALUES (12, 'Septimo', 1);