Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/08/2010, 12:48
jocasevi
 
Fecha de Ingreso: agosto-2008
Mensajes: 14
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: error al insertar formulario

El código es el siguiente:

<?php require_once('Connections/cnx.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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")) {
$insertSQL = sprintf("INSERT INTO inmueble (zonaID, tipoID, estadoID, titulo, dimensiones, habitaciones, aseos, garaje, detalle, precio, fotoprincipal, foto1, foto2, foto3, foto4, nombre, telefono1, telefono2, direccion, observaciones) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['zonaID'], "int"),
GetSQLValueString($_POST['tipoID'], "int"),
GetSQLValueString($_POST['estadoID'], "int"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['dimensiones'], "text"),
GetSQLValueString($_POST['habitaciones'], "text"),
GetSQLValueString($_POST['aseos'], "text"),
GetSQLValueString($_POST['garaje'], "text"),
GetSQLValueString($_POST['detalle'], "text"),
GetSQLValueString($_POST['precio'], "double"),
GetSQLValueString($_FILES['fotoprincipal']['name'], "text"),
GetSQLValueString($_FILES['foto1']['name'], "text"),
GetSQLValueString($_FILES['foto2']['name'], "text"),
GetSQLValueString($_FILES['foto3']['name'], "text"),
GetSQLValueString($_FILES['foto4']['name'], "text"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['telefono1'], "int"),
GetSQLValueString($_POST['telefono2'], "int"),
GetSQLValueString($_POST['direccion'], "text"),
GetSQLValueString($_POST['observaciones'], "text"));

mysql_select_db($database_cnx, $cnx);
$Result1 = mysql_query($insertSQL, $cnx) or die(mysql_error());

$destino="images/recibidas/fotoprincipal/";
copy($_FILES['fotoprincipal']['tmp_name'],$destino.$_FILES['fotoprincipal']['name']);

$destino="images/recibidas/";
copy($_FILES['foto1']['tmp_name'],$destino.$_FILES['foto1']['name']);
copy($_FILES['foto2']['tmp_name'],$destino.$_FILES['foto2']['name']);
copy($_FILES['foto3']['tmp_name'],$destino.$_FILES['foto3']['name']);
copy($_FILES['foto4']['tmp_name'],$destino.$_FILES['foto4']['name']);

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

mysql_select_db($database_cnx, $cnx);
$query_rsZonaID = "SELECT * FROM inmueble_zona ORDER BY zona ASC";
$rsZonaID = mysql_query($query_rsZonaID, $cnx) or die(mysql_error());
$row_rsZonaID = mysql_fetch_assoc($rsZonaID);
$totalRows_rsZonaID = mysql_num_rows($rsZonaID);

mysql_select_db($database_cnx, $cnx);
$query_rsTipo = "SELECT * FROM inmueble_tipo ORDER BY tipo ASC";
$rsTipo = mysql_query($query_rsTipo, $cnx) or die(mysql_error());
$row_rsTipo = mysql_fetch_assoc($rsTipo);
$totalRows_rsTipo = mysql_num_rows($rsTipo);

mysql_select_db($database_cnx, $cnx);
$query_rsEstado = "SELECT * FROM inmueble_estado ORDER BY estado ASC";
$rsEstado = mysql_query($query_rsEstado, $cnx) or die(mysql_error());
$row_rsEstado = mysql_fetch_assoc($rsEstado);
$totalRows_rsEstado = mysql_num_rows($rsEstado);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div id="cabecera">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/plantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>

<link href='icono.ico' rel='icon' type='image/x-ico'/>
<link href='icono.ico' rel='shortcut icon' type='image/x-ico'/>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Contactar con Costa Telde</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->

<link href="style.css" rel="stylesheet" type="text/css" />

<meta name="Description" content=""/>

<meta name="keywords" content="" />

</head>

<body>.....