Ver Mensaje Individual
  #9 (permalink)  
Antiguo 06/10/2008, 12:49
Avatar de jaronu
jaronu
 
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: Problemas con la fecha

te revise el code y a si podras insertar en la base la fecha en formato de MySQL año mes dia

Código PHP:


<?php require_once('Connections/conexionreformas.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"] == "form1")) {
$insertSQL sprintf("INSERT INTO general (`Nombre_ y _Apellidos`, Dirección, Teléfono, Email, `Plazo_ de_ inicio`, Localidad, Provincia, `Código_ postal`, Descripción, reforma) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Nombre_y_Apellidos'], "text"),
GetSQLValueString($_POST['Direccin'], "text"),
GetSQLValueString($_POST['Telfono'], "text"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Plazo_de_inicio'], "text"),
GetSQLValueString($_POST['Localidad'], "text"),
GetSQLValueString($_POST['Provincia'], "text"),
GetSQLValueString($_POST['Cdigo_postal'], "text"),
GetSQLValueString($_POST['Descripcin'], "text"),
GetSQLValueString($_POST['obra_realizar'], "text"));

mysql_select_db($database_conexionreformas$conexionreformas);
$Result1 mysql_query($insertSQL$conexionreformas) or die(mysql_error());
$insertGoTo "index.php";
if (isset(
$_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s"$insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction?>">
<table align="center">
<tr valign="baseline">
<td width="232" align="right" nowrap>Nombre y Apellidos:</td>
<td> <div align="center">
<input type="text" name="Nombre_y_Apellidos" value="" size="40" /> 
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Dirección:</td>
<td> <div align="center">
<input type="text" name="Direccin" value="" size="40"> 
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Teléfono:</td>
<td> <div align="center">
<input type="text" name="Telfono" value="" size="40"> 
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td> <div align="center">
<input type="text" name="Email" value="" size="40"> 
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Inicio de la obra:</td>
<td><div align="center">
<input type="text" name="Plazo_de_inicio" value=" <?php echo date("Y-m-d"); ?> " size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Localidad de la obra:</td>
<td> <div align="center">
<input type="text" name="Localidad" value="" size="40"> 
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Provincia de la obra:</td>
<td><div align="center">
<input type="text" name="Provincia" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Código postal:</td>
<td><div align="center">
<input type="text" name="Cdigo_postal" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Obra a realizar:<br />
(Ej: Reformar piso) </td>
<td><div align="center">
<input name="obra_realizar" type="text" id="obra_realizar" value="" size="40" />
</div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap>Descripci&oacute;n de la obra: </td>
<td><label>
<div align="center">
<textarea name="Descripcin" cols="34" rows="5" id="Descripcin"></textarea>
</div>
</label></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input name="submit" type="submit" value="Enviar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>
ahora para tu ver los datos tendras otro codigo que no enseñas, pero en el deberias incluir este trozo de codigo que te muestra la fecha en el formato que tu quieres:

Código PHP:

$fecha 
explode ("-",$row[fecha]);

echo 
$fecha[2]."-".$fecha[1]."-".$fecha[0]; 
si posteas el codigo donde haces la consulta ala base y no el insertar los datos que es el code que has posteado te dire donde lo tienes que poner

suerte y al toro que se dice aqui