Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/01/2016, 08:00
x_atrix
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Error php con mysql

Ya esta claro tu error ... mysql_select_db('nombre', $link); te falta el link de conexion ...
Mira a ver ahora ...

Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<link type="text/css" href="css/sunny/jquery-ui-1.8.13.custom.css" rel="stylesheet" /> 
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script> 
<script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js"></script> 
<script type="text/javascript"> 
  
$(function() { 
$( ".datepicker" ).datepicker(); 
}); 
</script> 
<body> 
<form id="form" name="form" method="post"> 
Fecha Inicio: 
<input type="text" name="fechaIni" class="datepicker"> 
<br> 
Fecha Final: 
<input type="text" name="fechaFin" class="datepicker"> 
<br> 
<input type="submit" value="Consultar"> 
</form> 
<h1>Consultas</h1> 
  
<?php 
function js2PhpTime($jsdate){ 
if(
preg_match('@(\d+)/(\d+)/(\d+)\s+(\d+):(\d+)@'$jsdate$matches)==1){ 
$ret mktime($matches[4], $matches[5], 0$matches[1], $matches[2], $matches[3]); 
//echo $matches[4] ."-". $matches[5] ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3]; 
}else if(preg_match('@(\d+)/(\d+)/(\d+)@'$jsdate$matches)==1){ 
$ret mktime(000$matches[1], $matches[2], $matches[3]); 
//echo 0 ."-". 0 ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3]; 

//return $ret; 

//echo date("Y-m-d", js2PhpTime('08/02/2011')); 
$fechaIni=""
if (isset(
$_POST['fechaIni'])) {$fechaIni $_POST['fechaIni'];} 
  
$fechaFin=""
if (isset(
$_POST['fechaFin'])) {$fechaFin $_POST['fechaFin'];}  
  
//$fechaMySQLFin = $_POST[implode( '-', array_reverse( explode( '/', $fechaFin ) ) )] ; 
$Inicio=date("Y-m-d"js2PhpTime($fechaIni)); 
$Final=date("Y-m-d"js2PhpTime($fechaFin)); 
$conectar=mysql_connect('localhost','root',''); 
if(
$conectar=NULL

printf("Error al conectar a la Base de datos"); 

  
mysql_select_db('resumenbeta'$conectar); 
echo 
$fechaIni
$resultado=mysql_query("SELECT Fecha, TipoDeProduccion, Region, Pais FROM resumenbeta WHERE Fecha BETWEEN '$Inicio' AND '$Final'"); 
if (
$resultado === false) { 
    echo 
mysql_errno() . '<br />'
    echo 
mysql_error(); 
    die(); 

if(
$row=mysql_fetch_array($resultado)){ 
echo 
"<table border='1' align='center'>\n"
echo 
"<tr><td>Fecha</td><td>TipoDeProducto</td><td>Region</td><td>Pais</td></tr> \n"
do{ 
  
echo 
"<tr><td>".$row["Fecha"]."</td><td>".$row["TipoDeProducto"]."</td><td>".$row["Region"]."</td><td>".$row["Pais"]."</td></tr> \n"
}while(
$row=mysql_fetch_array($resultado)); 
echo 
"</table>\n"

else{ 
echo 
"<center>No existen registros para el rango de esas fechas</center>"

  
?> 
  
  
</body> 
</html>