Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2010, 09:12
COsmik
 
Fecha de Ingreso: marzo-2010
Mensajes: 4
Antigüedad: 14 años, 2 meses
Puntos: 0
Pregunta

Hola buenos dias
tengo un formulario de insersion de registros,,con varios campos y uno para cargar imagen a mi carpeta "fotos" pero no me carga en la base de dattos


el tema es que me carga en un registro solamente la foto y en otro me carga los demas campos que puedo modificar para que me cargue todo en un mismo registro ,,estube probando varias formas pero no puedo encontrar la solucion muchas gracias!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!


Código PHP:
<?php require_once('../Connections/argentina.php'); ?>
<?php






function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}


if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "formulario")) {
  
$insertSQL sprintf("INSERT INTO obras1 (titulo, subtitulo, imagen, texto, fecha, descripcion) VALUES (%s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['textfield'], "text"),
                       
GetSQLValueString($_POST['textfield2'], "text"),
                       
GetSQLValueString($_POST['imagen1'], "text"),
                       
GetSQLValueString($_POST['textarea'], "text"),
                       
GetSQLValueString($_POST['textfield3'], "date"),
                       
GetSQLValueString($_POST['textarea2'], "text"));
                    
if (
is_uploaded_file($_FILES['imagen1']['tmp_name'])) {
                          
move_uploaded_file($_FILES['imagen1']['tmp_name'], "../fotos/" $_FILES['imagen1']['name']);
                          echo 
'La imagen '; echo $_FILES['imagen1']['name']. ' fue correctamente cargada!';
                          }

  
mysql_select_db($database_argentina$argentina);
  
$Result1 mysql_query($insertSQL$argentina) or die(mysql_error());
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
  
  
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
    background-color: #00446C;
}
.Estilo1 {    font-size: 18px;
    font-weight: bold;
}
.estilotextarea {width:400px;height:100px;border: 2px solid ;}
.estilotextarea2 {width:400px;height:20px;border: 2px solid ;}
-->
</style></head>

<body>
<div align="center">
  <p><img src="http://www.forosdelweb.com/f18/argtrab.png" width="745" height="266">
</p>
  <p>&nbsp;</p>
  <form action="<?php echo $editFormAction?>" method="POST" enctype="multipart/form-data" name="formulario" id="formulario">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="448" border="1">
      <tr>
        <td width="92">&nbsp;</td>
        <td width="340"><input type="text" name="textfield"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="text" name="textfield2"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><textarea name="textarea"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="imagen1" type="file" id="imagen1"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><textarea name="textarea2"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="textfield3" type="text" id="textfield3"></td>
      </tr>
    </table>
    <p>
      <input type="submit" name="Submit" value="Enviar">
    </p>
    <input type="hidden" name="MM_insert" value="formulario">
  </form>
  <p>&nbsp;</p>
  <p>&nbsp;  </p>
</div>
</body>
</html>
me sale este error
Notice: Undefined index: imagen1 in E:\Archivos de programa\EasyPHP-5.3.1\www\argentina\gestion\nuevoregistro2.php on line 44
La imagen 1.jpg fue correctamente cargada!La columna 'imagen' no puede ser nula

Última edición por COsmik; 11/03/2010 a las 11:59 Razón: mas info