Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/09/2011, 14:36
Avatar de JeMaGa
JeMaGa
 
Fecha de Ingreso: julio-2011
Ubicación: Bogota
Mensajes: 430
Antigüedad: 12 años, 9 meses
Puntos: 4
Checkbox en mysql

hola a todos yo tengo un formulario en que hay checkbox creados por una consulta mysql, y necesito insertar en mysql los checkbox seleccionados, listo me inserta solo un checkbox y cuando quiero incorporar los demas checkbos se me presenta el siguiente error

ERROR

Warning: implode() [function.implode]: Bad arguments. in C:\AppServ\www\InsertarArchivo.php on line 23

Warning: implode() [function.implode]: Bad arguments. in C:\AppServ\www\InsertarArchivo.php on line 25
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 '),())' at line 1

este es mi formulario de logica

InsertarArchivo.php

Código PHP:
Ver original
  1. <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Strict / / EN" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
  4.  
  5. <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
  6.  
  7. <link type="text/css" rel="stylesheet" href="estilo.css">
  8.  
  9. <?php
  10.  
  11. if ((isset($_POST['codigo']) && isset($_POST['nombre']) && isset($_POST['version']) && isset($_POST['Area']))
  12.  
  13. && ($_POST['codigo'] != "" || $_POST['nombre'] != "" || $_POST['version'] != "" || $_POST['Area'] != "" )) {
  14.  
  15.     $Codigo=$_POST['codigo'];
  16.  
  17.     $Nombre=$_POST['nombre'];
  18.  
  19.     $Version=$_POST['version'];
  20.  
  21.     $Area=implode(",",$_POST['Area']);
  22.  
  23.     $Area2=implode(",",$_POST['Area2']);
  24.    
  25.     $Area3=implode(",",$_POST['Area3']);
  26.  
  27.     $destino='archivos';
  28.  
  29.     $nom_archivo = $_FILES['archivo']['name'];
  30.  
  31.     $tipo = $_FILES['archivo']['type'];
  32.  
  33.     $size = $_FILES['archivo']['size'];
  34.  
  35.     $tamano=$_FILES['file']['size'];
  36.  
  37.        if($tamano < 500){
  38.  
  39.          copy($_FILES['archivo']['tmp_name'], $destino.'/'.$_FILES['archivo']['name']);
  40.  
  41.          require("Conexion.php");
  42.  
  43.          $sql = "insert into `datos` (`Codigo`,`Nombre`,`Version`,`Adjunto`,`Area`,`Area2`,`Area3`) values('{$Codigo}','{$Nombre}','{$Version}','{$_FILES['archivo']['name']}', (".$Area."),(".$Area2."),(".$Area3."))";
  44.  
  45.          mysql_query($sql, $Conexion) or die ( mysql_error());
  46.  
  47.          echo "<pre>";
  48.        
  49.          print_r($_POST);
  50.        
  51.          echo "</pre>";
  52.        
  53.          echo '<center><b><h3>Se insertaron los datos correctamente</a></h3></b></center>';
  54.        
  55.          echo '<center><b><h3><a href=CargarDocumento.php> Regresar </a></h3></b></center>';
  56.        
  57.       }else {
  58.  
  59.          echo ("El tamaño es superior al permitido");
  60.  
  61.        }
  62.  
  63. }else {
  64.  
  65.     $sindatos = "<center><font color=\"red\"  size=\"4\"><b>DEBE INGRESAR DATOS<b></font></center>";
  66.     include('CargarDocumento.php');
  67. }


CargarDocumento.php ----> el formulario de presentacion

Código HTML:
Ver original
  1. <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Strict / / EN" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
  4.  
  5. <script language="JavaScript" type="text/javascript" src="js/Ajax.js"></script>
  6.  
  7. <script type="text/javascript" src="js/jquery.min.js"></script>
  8.  
  9.  
  10.  
  11. <title>Cargar Documentos</title>
  12.  
  13. </head>
  14.  
  15. <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
  16.  
  17. <link type="text/css" rel="stylesheet" href="estilo.css">
  18.  
  19.  
  20. <div style="text-align: right;"><a href="CerrarSecion.php"><h6>Cerrar Sesion</h6></a></div>
  21.  
  22. <center><?php if (isset($sindatos)) echo $sindatos; ?></center>
  23.  
  24. <center><h2>CARGA DEL DOCUMENTO</h2><center>
  25.  
  26. <h3>Aqui usted podra ingresar nuevos documentos, pero estos solo pueden ser subidos cuando ya esten aprobados previamente,<br>
  27.  
  28. los campos con un <font color="red"><b>*</b></font> son obligatorios, debe seleccionar las areas que pueden ver los documentos a leer.</h3>
  29.  
  30. <form action="InsertarArchivo.php" method="post" enctype="multipart/form-data" name="form1">
  31.  
  32. <center><a href="MenuAdmi.php"><h3> Devlover </h3></a></center>
  33.  
  34. <center><br><table border ='2'>
  35.  
  36. <tr>
  37.  
  38. <td>
  39.  
  40. <center><IMG SRC="imagenes/LOGO.jpg" WIDTH=120 HEIGHT=100></center>
  41.  
  42. <h3><center>DATOS DEL DOCUMENTO</center></h3>
  43.  
  44. </td>
  45.  
  46. <td><br>
  47.  
  48. <center><h4><font color="red"><b>*</b></font> Codigo del Documento: <input type="text" name="codigo" id="documento" size="27"  value="<?php if(isset($Codigo)) echo $Codigo?>"/></h4></center>
  49.  
  50. <center><h4><font color="red"><b>*</b></font> Nombre del Documento: <input type="text" name="nombre" id="nombre" size="25" value="<?php if(isset($Nombre)) echo $Nombre?>" /></h4></center><?php if (isset($novalnum1)) echo $novalnum1?>
  51.  
  52. <center><h4><font color="red"><b>*</b></font> Version del Documento: <input type="text" name="version" id="version"  size="26"  value="<?php if(isset($Version)) echo $Version?>" /></h4></center><?php if (isset($novalnum2)) echo $novalnum2?>
  53.  
  54. <p align="center"><h4><font color="red"><b>*</b></font> Archivo  <input name="archivo" type="file" id="archivo"> </h4>
  55.  
  56. <h4><font color="red"><b>*</b></font> Area Correspondiente:<br><br><?php
  57.  
  58.                                                             require("Conexion.php");
  59.                                                            
  60.                                                             $resultado=mysql_query("Select * from `area`");
  61.                                                            
  62.                                                             while ($row = mysql_fetch_array($resultado)){
  63.                                                            
  64.                                                             echo "<input type=\"checkbox\" name=\"Area[]\" value=\"".$row['Cod.Area']."\">".$row['Nombre_Area']."<br>";
  65.                                                            
  66.                                                             }
  67.                                                            
  68.                                                             ?>
  69.  
  70. <center><p align="center"><input name="boton" type="submit" id="boton" value="ENVIAR"> <input name="boton" type="reset" id="boton" value="LIMPIAR"></p></center>
  71.  
  72. </td>
  73.  
  74. </tr>
  75.  
  76. </form>
  77.  
  78. </body>
  79.  
  80. </html>

agradesco toda la ayuda posible