Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/08/2010, 11:20
adicityofmetal
 
Fecha de Ingreso: julio-2010
Mensajes: 43
Antigüedad: 13 años, 10 meses
Puntos: 3
Dudas con insercionde datos en un DB

Hola de nuevo, dandoles lata una ocación mas pero esta vez palneo ser mas especifico en mi consulta.

(( :( Se que es un chirizo muy largo pero espero que me puedan ayudar.
Por adelantado Muchas Gracias!!))

Primero la idea es:
1. Subir dos archivos diferentes a una carpeta.

2.Que los nombres de estos archivos se almacenen en mi BD.

Lo primero creo tenenerlo y este es el código

Código HTML:
Ver original
  1. <form id="frmUno" name="frmUno" target="_self" method="post" enctype="multipart/form-data" action="../includes/cargaArchivo.php">
  2. <table width="1004" border="0" align="center" cellpadding="0" cellspacing="0">
  3.   <tr>
  4.     <td><table width="100%" border="0" align="center">
  5.         <tr>
  6.           <td valign="top"><p class="estilosmasweb">&nbsp;</p>
  7.                 <?php echo dameMenu();?>
  8.           </tabel>
  9.             <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" class="estilosmasweb">    
  10.                           <tr>
  11.                <td colspan="2"  style="text-align: center;">&nbsp;</td>
  12.                </tr>  
  13.               <tr>
  14.                <td colspan="2" class="TablaEncabezado" style="text-align: center;">Documentación</td>
  15.                </tr>
  16.                <tr>
  17.                <td class="fondoColumna" style="text-align: right;">Pre-Autorización Descarga</td>
  18.                <td class="fondoColumna" style="text-align: center;"><img src="../preAutorizacion/images/pdf.jpg" width="4%" align="center" style="cursor: hand" onclick="reporte('<?php echo $clave;?>');"></td>
  19.                </tr>
  20.                <tr>
  21.                <td class="fondoColumnaSin" style="text-align: right;">Pre-Autorización (Firmado)</td>
  22.                <td class="fondoColumnaSin" style="text-align: left;">
  23.                                     <input name="archivo1" type="file" size="35" >
  24.                                     <input name="enviar" type="submit" >
  25.                                     </td>
  26.                </tr>
  27.                <tr>
  28.                <td class="fondoColumna" style="text-align: right;">Buro de Crédito Descarga</td>
  29.                <td class="fondoColumna" style="text-align: center;"><img src="../preAutorizacion/images/pdf.jpg" width="4%" align="center" style="cursor: hand"  onclick="reportebc(<?php echo $clave;?>);"></td>
  30.                </tr>
  31.                <tr>                    
  32.                <td class="fondoColumnaSin" style="text-align: right;">Buro de crédito (Firmado)</td>
  33.                <td class="fondoColumnaSin" style="text-align: left;">
  34.                                     <input name="archivo2" type="file" size="35">
  35.                                     <input name="enviar" type="submit">
Estos formularios envian los archivos y los subo a mi carpeta con el sigueinte código en php.

Código PHP:
    //función para cargar archivos.
  
include("Configuration.php"); //llacma la conexión a la base de datos.
  
include("utilerias.php");
  
session_start();
   
$nombre $_FILES['archivo1']['name']; 
   
$tipo $_FILES['archivo1']['type']; 
   
$tamano $_FILES['archivo1']['size'];
   
$nombre2 $_FILES['archivo2']['name']; 
   
$tipo2 $_FILES['archivo2']['type']; 
   
$tamano2 $_FILES['archivo2']['size'];
   echo 
$nombre2;
   echo 
$nombre;      
  if (
move_uploaded_file($_FILES['archivo1']['tmp_name'], "../consolaClient/files/".$nombre)){
  }else{ 
             echo 
$msg"Ocurrio algun error al subir el archivo. No pudo guardarse."
           }
nombrePreBuro($strHostMYSQL,$strUserMYSQL,$strPWDMYSQL,$strDBMYSQL"../consolaClient/files/" .$nombre);/*  
           
  if (move_uploaded_file($_FILES['archivo2']['tmp_name'], "../consolaClient/files/".$nombre2)){
  }         
           else{ 
             echo $msg2= "Ocurrio algun error al subir el archivo. No pudo guardarse."; 
           }*/ 
Si se almacenana los archivos, pero cuando quiero enviar el nombre hacia la BD me manda el siguiente error el código.

<---Notice: Undefined variable: nombre in c:\archivos de programa\easyphp1-8\www\mas\includes\utilerias.php on line 373

Notice: Undefined variable: nom in c:\archivos de programa\easyphp1-8\www\mas\includes\utilerias.php on line 385
insert into usuariodoc set clave_doc=2 (clave_usuario, archivo_usdoc, fecha_usdoc) values ('9','',now())No fue posible ejecutar la consulta[1064-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 '(clave_usuario, archivo_usdoc, fecha_usdoc) values ('9','',now(] --->

Bueno despues de mostrarles el error, les mostraré a donde se supone que debe realiar el insert de los datos en la BD.

Código PHP:
function nombrePreBuro(){
     include(
"Configuration.php");
     
$link=mysql_connect($strHostMYSQL$strUserMYSQL$strPWDMYSQL$nombre);
        
mysql_select_db($strDBMYSQL,$link);
        if(
mysql_errno()>0)
        {     
            
$strResultOp "No fue posible validar el usuario.";
            
$strInfoTec "No fue posible localizar el host[".mysql_errno()."-".mysql_error()."]";
            
$strModulo $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".basename($_SERVER['PHP_SELF']);
            
$strParameters"host:".$strHostMYSQL."~-user:".$strUserMYSQL."~PWD:".$strPWDMYSQL;
        } 
        else
        {
                
$strSql ="insert into usuariodoc set clave_doc=2 (clave_usuario, archivo_usdoc, fecha_usdoc) ";
                
$strSql .=" values ('".$_SESSION["cusuario"]."','" .$nombre"',now())";
               echo    
$strSql;
                
$Result mysql_query($strSql);
                if(
mysql_errno()>0){
                    
$strResultOp "No fue posible validar el usuario.";
                    
$strInfoTec "No fue posible ejecutar la consulta[".mysql_errno()."-".mysql_error()."]";
                    
$strModulo $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/".basename($_SERVER['PHP_SELF']);
                    echo 
$strInfoTec;
            }
        }
     } 
:( Se que es un chirizo muy largo pero espero que me puedan ayudar.
Por adelantado Muchas Gracias!!