Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/01/2016, 07:36
jjgonzalesf
 
Fecha de Ingreso: enero-2016
Mensajes: 19
Antigüedad: 8 años, 3 meses
Puntos: 0
Respuesta: Error php con mysql

se ha verificado lo indicado al generar la consulta en mysql me busca, pero al llevar la sentencia al php me sigue apareciendo el mismo error help.

SENTENCIA EN MY SQL

Código MySQL:
Ver original
  1. SELECT `Fecha`,`TipoDeProducto`, `Pais`, `Cliente` FROM `resumenbeta` WHERE Fecha between DATE("2015-12-27") and DATE("2015-12-30")

SENTENCIA EN PHP

Código PHP:
Ver original
  1. mysql_select_db('resumenbeta');
  2. echo $fechaIni;
  3. $resultado=mysql_query("SELECT Fecha, TipoDeProduccion, Region, Pais FROM resumenbeta WHERE Fecha BETWEEN '$Inicio' AND '$Final'");

CODIGO PHP COMPLETO CON LA MODIFICACION DE LA SENTECIA
Código PHP:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title></title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <link type="text/css" href="css/sunny/jquery-ui-1.8.13.custom.css" rel="stylesheet" />
  8. <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
  9. <script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js"></script>
  10. <script type="text/javascript">
  11.  
  12. $(function() {
  13. $( ".datepicker" ).datepicker();
  14. });
  15. </script>
  16. <body>
  17. <form id="form" name="form" method="post">
  18. Fecha Inicio:
  19. <input type="text" name="fechaIni" class="datepicker">
  20. <br>
  21. Fecha Final:
  22. <input type="text" name="fechaFin" class="datepicker">
  23. <br>
  24. <input type="submit" value="Consultar">
  25. </form>
  26. <h1>Consultas</h1>
  27.  
  28. <?php
  29. function js2PhpTime($jsdate){
  30. if(preg_match('@(\d+)/(\d+)/(\d+)\s+(\d+):(\d+)@', $jsdate, $matches)==1){
  31. $ret = mktime($matches[4], $matches[5], 0, $matches[1], $matches[2], $matches[3]);
  32. //echo $matches[4] ."-". $matches[5] ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3];
  33. }else if(preg_match('@(\d+)/(\d+)/(\d+)@', $jsdate, $matches)==1){
  34. $ret = mktime(0, 0, 0, $matches[1], $matches[2], $matches[3]);
  35. //echo 0 ."-". 0 ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3];
  36. }
  37. //return $ret;
  38. }
  39. //echo date("Y-m-d", js2PhpTime('08/02/2011'));
  40. $fechaIni="";
  41. if (isset($_POST['fechaIni'])) {$fechaIni = $_POST['fechaIni'];}
  42.  
  43. $fechaFin="";
  44. if (isset($_POST['fechaFin'])) {$fechaFin = $_POST['fechaFin'];}
  45.  
  46. //$fechaMySQLFin = $_POST[implode( '-', array_reverse( explode( '/', $fechaFin ) ) )] ;
  47. $Inicio=date("Y-m-d", js2PhpTime($fechaIni));
  48. $Final=date("Y-m-d", js2PhpTime($fechaFin));
  49. $conectar=mysql_connect('localhost','root','');
  50. if($conectar=NULL)
  51. {
  52. printf("Error al conectar a la Base de datos");
  53. }
  54.  
  55. mysql_select_db('resumenbeta');
  56. echo $fechaIni;
  57. $resultado=mysql_query("SELECT Fecha, TipoDeProduccion, Region, Pais FROM resumenbeta WHERE Fecha BETWEEN '$Inicio' AND '$Final'");
  58.  
  59. if($row=mysql_fetch_array($resultado)){
  60. echo "<table border='1' align='center'>\n";
  61. echo "<tr><td>Fecha</td><td>TipoDeProducto</td><td>Region</td><td>Pais</td></tr> \n";
  62. do{
  63.  
  64. echo "<tr><td>".$row["Fecha"]."</td><td>".$row["TipoDeProducto"]."</td><td>".$row["Region"]."</td><td>".$row["Pais"]."</td></tr> \n";
  65. }while($row=mysql_fetch_array($resultado));
  66. echo "</table>\n";
  67. }
  68. else{
  69. echo "<center>No existen registros para el rango de esas fechas</center>";
  70. }
  71.  
  72. ?>
  73.  
  74.  
  75. </body>
  76. </html>