Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/04/2005, 22:38
EFranz
 
Fecha de Ingreso: febrero-2003
Mensajes: 15
Antigüedad: 21 años, 1 mes
Puntos: 1
Serios Problemas para guardar la ruta de una imagen y trabajo con Dreamwaver 2004



He intentado comprender los tutoriales que hay en este sitio, pero el detalle es que cuando Dreamweaver me crear el codigo para el formulario que utilizo para insertar un registro, el codigo es muy distinto al que hay en los tutoriales.

Trate de adaptarlo y solo logre que la imagen pase del disco duro a la carpeta del hosting, pero cuando reviso la tabla resulta que no guarda nada en el campo de "imagen1"

Probe colocando la ruta de la imagen para ver si por lo menos veo la imagen que esta guardada y nada de eso!



he pasado 4 días en esto y de verdad estoy full desanimado!

Si alguien me puede ayudar se los agradezco!!!


No hagan caso a la segunda tabla!
Código PHP:
<form action="<?php echo $editFormAction?>" method="POST" enctype="multipart/form-data" name="insertarahora" id="insertarahora">
  <p>Dato en tabla01 
    <input name="dato_prueba1" type="text" id="dato_prueba1" size="10" maxlength="10">
    <input name="id_prueba1" type="hidden" id="id_prueba1" value="<?php echo ($row_max_tabla_1y2['max(id_prueba1)']+1); ?>">
  </p>
  <p>Dato en tabla02 
    <input name="dato_prueba2" type="text" id="dato_prueba2" size="10" maxlength="10">
    <input name="id_prueba2" type="hidden" id="id_prueba2" value="<?php echo ($row_max_tabla_1y2['max(id_prueba2)']+1); ?>">
</p>
  <p>Imagen: 
    <input name="imagen1" type="file" id="imagen1">
</p>

//Intento fallido para ver la imagen
  <p><img src="<?php echo $row_im['imagen1']; ?>" width="190" height="100"> <?php echo $row_im['imagen1']; ?></p>
  <p>
    <input type="submit" name="Submit" value="Enviar">
  </p>
  <input type="hidden" name="MM_insert" value="insertarahora">
</form>

Código 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"] == "insertarahora")) {
  
$insertSQL sprintf("INSERT INTO prueba02 (id_prueba2, dato_prueba2) VALUES (%s, %s)",
                       
GetSQLValueString($_POST['id_prueba2'], "int"),
                       
GetSQLValueString($_POST['dato_prueba2'], "text"));

  
mysql_select_db($database_gcd$gcd);
  
$Result1 mysql_query($insertSQL$gcd) or die(mysql_error());

  
$insertGoTo "00_insertprueba.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "insertarahora")) {

//INICIO          ESTO FUE LO QUE PUDE ADAPTAR DE LO QUE ENCONTRE EN FOROS DEL WEB
$newimage sprintf ("imgclientes/%s"$imagen1_name);
move_uploaded_file($imagen1$newimage);
$image1 $newimage;
//FIN

  
$insertSQL sprintf("INSERT INTO prueba01 (id_prueba1, dato_prueba1, imagen1) VALUES (%s, %s, %s)",
                       
GetSQLValueString($_POST['id_prueba1'], "int"),
                       
GetSQLValueString($_POST['dato_prueba1'], "text"),
                       
GetSQLValueString($_POST['$imagen1'], "text"));
//Aquí cambie $imagen1 por el valor que Dreamweaver le colocó originalmente que era: 'imagen1', pensé que buscaba una variable pero nada!

// Porque utiliza esto: GetSQLValueString tengo un libro e MySQL y otro de PHP y no encontre nada como eso!

  
mysql_select_db($database_gcd$gcd);
  
$Result1 mysql_query($insertSQL$gcd) or die(mysql_error());



  
$insertGoTo "00_insertprueba.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_gcd$gcd);
$query_max_tabla_1y2 "SELECT max(id_prueba1), max(id_prueba2) FROM prueba01, prueba02";
$max_tabla_1y2 mysql_query($query_max_tabla_1y2$gcd) or die(mysql_error());
$row_max_tabla_1y2 mysql_fetch_assoc($max_tabla_1y2);
$totalRows_max_tabla_1y2 mysql_num_rows($max_tabla_1y2);

mysql_select_db($database_gcd$gcd);
$query_im "SELECT imagen1 FROM prueba01";
$im mysql_query($query_im$gcd) or die(mysql_error());
$row_im mysql_fetch_assoc($im);
$totalRows_im mysql_num_rows($im);
?>

Ah! por cierto, esto fue lo que puse en la tabla prueba01: id_prueba1, dato_prueba1, imagen1 y dentro de este último le coloque:
imgclientes/Colinas azules.jpg sin comillas ni nada, bueno, no se si debería llevar comillas!

Bueno agradezco de antemano cualquier ayuda eh!