Foros del Web » Programando para Internet » PHP »

Problema al enviar una fecha por GET

Estas en el tema de Problema al enviar una fecha por GET en el foro de PHP en Foros del Web. Hola! Nada primero deciros que me estoy iniciando en el tema de PHP. La duda que tengo es que cuando quiero enviar una fecha en ...
  #1 (permalink)  
Antiguo 12/05/2008, 09:03
 
Fecha de Ingreso: mayo-2008
Mensajes: 10
Antigüedad: 15 años, 11 meses
Puntos: 0
Problema al enviar una fecha por GET

Hola! Nada primero deciros que me estoy iniciando en el tema de PHP. La duda que tengo es que cuando quiero enviar una fecha en formato dd/mm/yyyy a otra pagina no consigo hacerlo, me sigue saliendo en formato sql. :

Os lo muestro:

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

$hoy 
date("d/m/Y");

function 
cambiaf_a_normal($fecha/*funcion para convertir la fecha de formato americano a europeo */
{
    
ereg"([0-9]{2,4})/([0-9]{1,2})/([0-9]{1,2})"$fecha$mifecha);
    
$lafecha=$mifecha[3]."/".$mifecha[2]."/".$mifecha[1];
    return 
$lafecha;
}

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;
}
}

if ((isset(
$_GET['id_aulas'])) && ($_GET['id_aulas'] != "") && (isset($_GET['id_turno'])) && ($_GET['id_turno'] != "") && (isset($_GET['fecha'])) && ($_GET['fecha'] != "")) 
{
  
$deleteSQL sprintf("DELETE FROM reservas WHERE id_aulas=%s AND id_turno=%s AND fecha=%s",
                       
GetSQLValueString($_GET['id_aulas'], "int"),
                       
GetSQLValueString($_GET['id_turno'], "int"),
                       
GetSQLValueString($_GET['fecha'], "date"));

  
mysql_select_db($database_BDreservas$BDreservas);
  
$Result1 mysql_query($deleteSQL$BDreservas) or die(mysql_error());

  
$deleteGoTo "calendario.php?id_aulas=".$_GET['id_aulas']."&fecha=".cambiaf_a_normal(date("d/m/Y"$hoy));
  if (isset(
$_SERVER['QUERY_STRING'])) 
  {
    
$deleteGoTo .= (strpos($deleteGoTo'?')) ? "&" "?";
    
$deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$deleteGoTo));
}
?>
En el siguiente apartado es dnd tengo el problema, que es que no se si lo estoy pasando bien, x lo demas todo me va bien.

Código PHP:
$deleteGoTo "calendario.php?id_aulas=".$_GET['id_aulas']."&fecha=".cambiaf_a_normal(date("d/m/Y"$hoy)); 
Espero vuestra respuesta, Muchas Gracias de antemano.
  #2 (permalink)  
Antiguo 12/05/2008, 09:15
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: Problema al enviar una fecha por GET

Tu función cambiaf_a_normal solo acepta un parámetro y es una fecha en formato SQL, para pasarla a un formato Y/m/d.

Tu le estas pasando una fecha en formato d/m/Y, por lo que ya la generas directamente con date, entonces solo cambia esta linea:
Código PHP:
 $deleteGoTo "calendario.php?id_aulas=".$_GET['id_aulas']."&fecha=".date"Y/m/d" ); 
Saludos.
  #3 (permalink)  
Antiguo 12/05/2008, 09:24
 
Fecha de Ingreso: mayo-2008
Mensajes: 10
Antigüedad: 15 años, 11 meses
Puntos: 0
Re: Problema al enviar una fecha por GET

Gator V muchas gracias por responder pero sigue sin funcionar... ademas me suena ya de haber probado esa manera. Seguire probando.
  #4 (permalink)  
Antiguo 12/05/2008, 09:26
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: Problema al enviar una fecha por GET

Cuando haces eso, ¿que ves en tu URL al hacer la redirección?

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:55.