PHP - Problema, al imprimir reporte

 
Vista:
sin imagen de perfil

Problema, al imprimir reporte

Publicado por Miguel (3 intervenciones) el 09/07/2013 17:46:35
Buenos días, tengo un pequeño problema, le doy vuelta al código y no le encuentro la falla, y al imprimir el código me muestran los siguientes errores

1
2
3
4
5
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /home/dominio/public_html/resultado.php on line 348
 
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /home/dominio/public_html/resultado.php on line 349
 
Warning: mysql_free_result() expects parameter 1 to be resource, null given in /home/dominio/public_html/resultado.php on line 350


Mi código es el siguiente.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
for ($j=0; $j <$num_resultados_hor; $j++)
				{
				$rowHor = mysql_fetch_array($resultado_hor);
					$em=0;
					$em2=0;
					$em_s=0;
					$em2_s=0;
					$feriado=0;
					$justificacion=0;
					$permiso=0;
 
					$resultado_mar = mysql_query($consulta_mar);
					$num_resultados_mar = mysql_num_rows($resultado_mar);
 
	    			for ($k=0; $k <$num_resultados_mar; $k++)
					{
					$rowMar = mysql_fetch_array($resultado_mar);
							if (compara_fechas($rowHor["dia"],$rowMar["fecha"])==0) {
								if (strtotime($rowMar["hora"])<=strtotime("10:30") and $em==0){
									$hora=$rowMar["hora"];
									$em=1;
									if (strtotime($rowMar["hora"])>strtotime($rowHor["turno1_ent"]))
										$tardanza=resta($rowMar["hora"],$rowHor["turno1_ent"]);
									else
										$tardanza="00:00";
								}
								else{
									if (strtotime($rowMar["hora"])<=strtotime("14:30") and strtotime($rowMar["hora"])>strtotime($rowHor["turno1_ent"])){
										$hora_s=$rowMar["hora"];
										$em_s=1;
									}
									else {
										if (strtotime($rowMar["hora"])<=strtotime("17:45") and $em2==0){
											$hora2=$rowMar["hora"];
											$em2=1;
											if (strtotime($rowMar["hora"])>strtotime($rowHor["turno2_ent"]))
												$tardanza2=resta($rowMar["hora"],$rowHor["turno2_ent"]);
											else
												$tardanza2="00:00";
										}
										else {
											if (strtotime($rowMar["hora"])>strtotime($rowHor["turno2_ent"])) {
												$hora2_s=$rowMar["hora"];
												$em2_s=1;
											}
										}
									}
								}
 
							}
 
					}
 
 
					$resultado_fer = mysql_query($consulta_fer);
					$num_resultados_fer = mysql_num_rows($resultado_fer);
 
	    			for ($i=0; $i <$num_resultados_fer; $i++)
					{
						$rowFer = mysql_fetch_array($resultado_fer);
							if (compara_fechas($rowHor["dia"],$rowFer["diaFeriado"])==0) {
								$feriado=1;
							}
					}
 
 
					$resultado_per = mysql_query($consulta_per);
					$num_resultados_per = mysql_num_rows($resultado_per);
 
	    			for ($i=0; $i <$num_resultados_per; $i++)
					{
						$rowPer = mysql_fetch_array($resultado_per);
						if ($rowPer["cod_tip"]==NULL) {
							if (compara_fechas($rowHor["dia"],$rowPer["fec_ini"])>=0 and compara_fechas($rowHor["dia"],$rowPer["fec_fin"])<=0) {
								$justificacion=1;
								$motivo_j=$rowPer["motivo"];
							}
						}
						else{
							if (compara_fechas($rowHor["dia"],$rowPer["fecha"])==0) {
								$permiso=1;
								$motivo_p=$rowPer["motivo"];
								$hora_ini=$rowPer["hora_ini"];
								$hora_fin=$rowPer["hora_fin"];
 
							}
						}
					}
 
 
					if ($feriado==1){
						$hora='FERIADO';
						$hora2='FERIADO';
						$hora_s='';
						$hora2_s='';
						$tardanza='';
						$tardanza2='';
					}
					else {
						if ($justificacion==1){
							$hora=$motivo_j;
							if ($rowHor["turno2_dsc"]!=NULL)
								$hora2=$motivo_j;
							else
								$hora2='';
							$hora_s='';
							$hora2_s='';
							$tardanza='';
							$tardanza2='';
						}
						else{
							if ($permiso==1){
								if (strtotime($hora_ini)<=strtotime("14:00")){
									$hora=$motivo_p.' '.$hora_ini.'-'.$hora_fin;
									$hora_s='';
									$tardanza='';
								}
								else {
									$hora2=$motivo_p.' '.$hora_ini.'-'.$hora_fin;
									$hora2_s='';
									$tardanza2='';
								}
							}
							else{
									if ($em==0)
										$hora='-';
									if ($em_s==0)
										$hora_s='';
									if (($em==0) and ($em_s==0))
										$tardanza='';
									if ($rowHor["turno2_dsc"]!=NULL) {
										if ($em2==0)
											$hora2='-';
										if ($em2_s==0)
											$hora2_s='';
										if (($em2==0) and ($em2_s==0))
											$tardanza2='';
									}
									else{
										$hora2='';
										$hora2_s='';
										$tardanza2='';
									}
							}
						}
					}
 
 
			?>

line 348
line 349
line 350
1
2
3
4
5
<?PHP
  mysql_free_result($resultado_fer);
  mysql_free_result($resultado_per);
  mysql_free_result($resultado_hor);
  ?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Problema, al imprimir reporte

Publicado por xve (6935 intervenciones) el 09/07/2013 20:38:59
Hola Miguel, la verdad es que en la programación de paginas web, nunca utilizo mysql_free_result, ya que al finalizar el script, se libera toda la memoria utilizada por las base de datos de manera automática.

De todas maneras, el warning (no es un error) que te da, podría ser porque las variables resultado_fer, resultado_per y resultado_hor no se hayan utilizado?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar