Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/01/2008, 14:14
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Re: Problemas insertando datos

Encabezado
Código PHP:
<?php require_once('Connections/incomed.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form1")) {

$ediciondir'images/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen']['tmp_name'], $uploaddir $_FILES['imagen']['name']);    
$filename $_FILES['imagen']['name'];
if(empty(
$filename)) 
$filename ""

$ediciondir'images2/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen2']['tmp_name'], $uploaddir $_FILES['imagen2']['name']);    
$filename2 $_FILES['imagen2']['name'];
if(empty(
$filename2)) 
$filename2 ""

$ediciondir'images3/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen3']['tmp_name'], $uploaddir $_FILES['imagen3']['name']);    
$filename3 $_FILES['imagen3']['name'];
if(empty(
$filename3)) 
$filename3 ""

$ediciondir'images4/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen4']['tmp_name'], $uploaddir $_FILES['imagen4']['name']);    
$filename4 $_FILES['imagen4']['name'];
if(empty(
$filename4)) 
$filename4 ""

$ediciondir'images5/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen5']['tmp_name'], $uploaddir $_FILES['imagen5']['name']);    
$filename5 $_FILES['imagen5']['name'];
if(empty(
$filename5)) 
$filename5 ""

$ediciondir'images6/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen6']['tmp_name'], $uploaddir $_FILES['imagen6']['name']);    
$filename6 $_FILES['imagen6']['name'];
if(empty(
$filename6)) 
$filename6 ""

$ediciondir'images7/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen7']['tmp_name'], $uploaddir $_FILES['imagen7']['name']);    
$filename7 $_FILES['imagen7']['name'];
if(empty(
$filename7)) 
$filename7 ""

$ediciondir'images8/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen8']['tmp_name'], $uploaddir $_FILES['imagen8']['name']);    
$filename8 $_FILES['imagen8']['name'];
if(empty(
$filename8)) 
$filename8 ""

  
$insertSQL sprintf("INSERT INTO ambulancias (titulo, coment, flash, foto1, foto2, foto3, foto4, foto5, foto6, imgprinc) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['coment'], "text"),
                       
GetSQLValueString($filename"text"),
                       
GetSQLValueString($filename2"text"),
                       
GetSQLValueString($filename3"text"),
                       
GetSQLValueString($filename4"text"),
                       
GetSQLValueString($filename5"text"),
                       
GetSQLValueString($filename6"text"),
                       
GetSQLValueString($filename7"text"),
                       
GetSQLValueString($filename8"text"));

  
mysql_select_db($database_incomed$incomed);
  
$Result1 mysql_query($insertSQL$incomed) or die(mysql_error());

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

mysql_select_db($database_incomed$incomed);
$query_Recordset1 "SELECT * FROM ambulancias";
$Recordset1 mysql_query($query_Recordset1$incomed) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>