Programación Web y Scripting > PHP

 No Me Almacena La Fecha

(1/1)

neorent:
que tal amigo de solocodigos, bueno les paso a comentar, estoy almacenando la hora y fecha en mi tabla pero no me guarda la hora le presento el code donde almaceno.


esta se llama graba_db.php


--- Código: Text --- <?php    include("conex.php");   include("myfunc.php");   $link=Conectarse();    $i_nombre=$_GET['nombre'];       $i_area=$_GET['area'];   $i_direcc=$_GET['direccion'];   $i_unidad=$_GET['unidad'];   $i_edificio=$_GET['edificio'];   $i_piso=$_GET['piso'];   $i_correo=$_GET['correo'];   $i_fono=$_GET['fono'];   $i_requerimiento=$_GET['requerimiento'];   $i_fecha=cambiaf_a_mysql($_GET['fecha']);   $i_hora=$_GET['hora'];   mysql_query("insert into tbl_maestra (nombre_usuario,area_usuario,direccion_usuario,depto_usuario,edificio,piso,correo_usuario,fono_anexo,tipo_requerimiento,fecha_solicitud,hora_solicitud) values ('$i_nombre','$i_area','$i_direcc','$i_unidad','$i_edificio','$i_piso','$i_correo','$i_fono','$i_requerimiento','$i_fecha','i_hora')",$link);        header("Location: ingreso_db.php");?>   
y este es donde ingreso.


--- Código: Text --- <html> <head>    <title>Ingreso Solicitud</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body><p> </p><?php include("formato.php"); ?><?php CabeceraPagina(); ?> <h3>Ingreso de Solicitudes </h3><FORM ACTION="graba_db.php" method="get"> <TABLE> <TR>    <TD width="129">Nombre Solicitante:</TD>    <TD width="428"><INPUT NAME="nombre" TYPE="text" id="nombre" tabindex="1" SIZE="50" MAXLENGTH="100"></TD> </TR><TR>  <TD>Area:</TD>  <TD><?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_area ORDER BY `id_area` ASC ");   echo '<select name="area" tabindex="2">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["des_area"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Dirección: </TD>  <TD><?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_direcciones ORDER BY `id_direccion` ASC ");   echo '<select name="direccion"tabindex="3">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["des_direccion"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Unidad / Depto.:</TD>  <TD><?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_unidades ORDER BY `id_unidad` ASC ");   echo '<select name="unidad"tabindex="4">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["des_unidad"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Edificio:</TD>  <TD>    <?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_edificio ORDER BY `id_edificio` ASC ");   echo '<select name="edificio" tabindex="5">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["des_edificio"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Piso:</TD>  <TD><?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_pisos ORDER BY `id_piso` ASC ");   echo '<select name="piso" tabindex="6">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["des_piso"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Correo Electronico: </TD>  <TD><input name="correo" type="text" id="correo" tabindex="7" size="20" maxlength="30"></TD></TR><TR>  <TD>Tipo Requerimiento :</TD>  <TD><?php  $link=mysql_connect("localhost","root", "");  $link1=mysql_select_db("db_soporte",$link);  $result=mysql_query("select * from tbl_fallas ORDER BY `id_falla` ASC ");   echo '<select name="requerimiento" tabindex="8">';  //Generamos el menu desplegable  while ($row=mysql_fetch_array($result))  {echo '<option>'.$row["desc_falla"];}  echo "</select>";  mysql_free_result($result);   ?></TD></TR><TR>  <TD>Fono / Anexo: </TD>  <TD><input name="fono" type="text" id="fono" tabindex="9" size="10" maxlength="10"></TD></TR><TR>  <TD>Fecha Solicitud: </TD>  <TD><input name="fecha" type="text"  id="fecha" tabindex="10" value="<?php echo date("d/m/Y")?>" size="15" maxlength="20" readonly="true"></TD></TR><TR>  <TD>Hora Solicitud </TD>  <TD><input name="hora" type="text"  id="hora" tabindex="11" value="<?php echo date("H:i:s")?>" size="15" maxlength="20" readonly="true"></TD></TR></TABLE> <input type="submit" name="save" value="Grabar"></FORM> <hr color="#000000"> <?php    include("conex.php");    include("myfunc.php");   $link=Conectarse();    $result=mysql_query("select * from tbl_maestra ORDER BY `folio` DESC",$link); ?><table border=1 cellpadding=1 cellspacing=1 bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000">  <tr>    <td width="64"> Nº Solicitud  </td>    <td width="61"> Fecha Solicitud  </td>    <td width="68"> Hora Solicitud  </td>    <td width="66"> Nombre Solicitante </td>    <td width="83"> Unid.Depto. </td>    <td width="84"> Fono/Anexo </td>    <td width="96"> Requerimiento Solicitado </td>    <td width="84"> Tecnico Asignado </td>    <td width="96"> Estado Atencion </td>  </tr>  <?php          while($row = mysql_fetch_array($result)) {       printf("<tr><td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    <td> %s</td>    </tr>", $row["folio"],cambiaf_a_normal($row["fecha_solicitud"]),$row["hora_solicitud"],$row["nombre_usuario"],$row["depto_usuario"],$row["fono_anexo"],$row["tipo_requerimiento"],$row["tecnico_asignado"],$row["estado_atencion"]);     }    mysql_free_result($result);    mysql_close($link);    ?></table><?php PiePagina(); ?></body> </html>   
se supone que en el input hora le asigno el valor de la hora del sistema lo mismo que en el input de fecha, pero cuando la almaceno en la tabla me la graba en asi 00:00:00 entonces no comprendo que es lo que pasa si alguien me puede decir donde esta el error o si debo cambiar algo se lo agradeceria llevo 5 horas tratando de solucionar esto y no me resulta, muchas gracias a todos.

Altareum:
Si el campo fecha te lo guarda como 00:00:00, es porque definiste el campo de la tabla como time (en la base de datos).... cambialo a tipo date.

Altareum.

neorent:

--- Cita de: "Altareum" --- Si el campo fecha te lo guarda como 00:00:00, es porque definiste el campo de la tabla como time (en la base de datos).... cambialo a tipo date.

Altareum.
--- Fin de la cita ---
hola que tal gracias por la ayuda pero sabes cuando lo cambie a date me lo graba asi 000-00-00 osea como fecha no hay otra forma de poder hacerlo, gracias.

neorent:
hola que tal gracias a todos pero saben el problema no era nada de php ni mysql el problema era yo :P  me flato algo miren, esta es la que digo que esta mala.



--- Código: Text --- <?php    include("conex.php");   include("myfunc.php");   $link=Conectarse();    $i_nombre=$_GET['nombre'];       $i_area=$_GET['area'];   $i_direcc=$_GET['direccion'];   $i_unidad=$_GET['unidad'];   $i_edificio=$_GET['edificio'];   $i_piso=$_GET['piso'];   $i_correo=$_GET['correo'];   $i_fono=$_GET['fono'];   $i_requerimiento=$_GET['requerimiento'];   $i_fecha=cambiaf_a_mysql($_GET['fecha']);   //$i_hora=date("H:i:s");   $i_hora=$_GET['hora'];   //$i_hora=$hoy   mysql_query("insert into tbl_maestra (nombre_usuario,area_usuario,direccion_usuario,depto_usuario,edificio,piso,correo_usuario,fono_anexo,tipo_requerimiento,fecha_solicitud,hora_solicitud) values ('$i_nombre','$i_area','$i_direcc','$i_unidad','$i_edificio','$i_piso','$i_correo','$i_fono','$i_requerimiento','$i_fecha','i_hora')",$link);        header("Location: ingreso_db.php");?>   
y esta es la que esta buena.


--- Código: Text --- <?php    include("conex.php");   include("myfunc.php");   $link=Conectarse();    $i_nombre=$_GET['nombre'];       $i_area=$_GET['area'];   $i_direcc=$_GET['direccion'];   $i_unidad=$_GET['unidad'];   $i_edificio=$_GET['edificio'];   $i_piso=$_GET['piso'];   $i_correo=$_GET['correo'];   $i_fono=$_GET['fono'];   $i_requerimiento=$_GET['requerimiento'];   $i_fecha=cambiaf_a_mysql($_GET['fecha']);   //$i_hora=date("H:i:s");   $i_hora=$_GET['hora'];   //$i_hora=$hoy   mysql_query("insert into tbl_maestra (nombre_usuario,area_usuario,direccion_usuario,depto_usuario,edificio,piso,correo_usuario,fono_anexo,tipo_requerimiento,fecha_solicitud,hora_solicitud) values ('$i_nombre','$i_area','$i_direcc','$i_unidad','$i_edificio','$i_piso','$i_correo','$i_fono','$i_requerimiento','$i_fecha','$i_hora')",$link);        header("Location: ingreso_db.php");?>   
en la variable me falto agregar $i_hora jejeje y yo puse i_hora jejeje sorry por la molestia pero me di cuenta solito del problema

Navegación

[0] Índice de Mensajes

Ir a la versión completa