• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Problems accessing a php address depending of a post paramenter

I have a php file to which I can access without problems. However, depending on the post parameter I send, an abort connection error appears.

What could happen?

Thank you.
0
gplana
Asked:
gplana
  • 10
  • 3
  • 2
1 Solution
 
Marco GasiFreelancerCommented:
Can you show the code you're using and the exact error message you get, please?
0
 
COBOLdinosaurCommented:
So you are not going to post the text of the error, or a link to the page with a problem, or any code, and we are just intuitively going tell you what is wrong?????

Cd&
0
 
gplanaAuthor Commented:
The page is on a private server. There is no access from internet.
There is also no error, but on firebug I get a "connection abort" after about 300ms timing.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
gplanaAuthor Commented:
If I made an ajax call from jquery and access to the status attribute, I get a 0 as its value.
0
 
COBOLdinosaurCommented:
Then there is an error on the server and you should be able to see it in the error log.

Cd&
0
 
gplanaAuthor Commented:
I suspect is a character encoding issue. Could it be?
0
 
gplanaAuthor Commented:
Looking at logs, the error I'm getting are: zend_mm_heap_corrupted.
0
 
Marco GasiFreelancerCommented:
Try to increment the value of output_buffering in php.ini
0
 
gplanaAuthor Commented:
I tryied to add this line at the beginning of my php file:
      ini_set('output_buffering',10000);

but the same happens.

I discovered something: this php file has a big SQL statement (four SELECTs joined by UNIONs clauses) and then I use mssql_query to send this query to an SQL-Server database.

What I discovered is if I remove one of the 4 selects, whatever of them I remove, then it works, so I though about a memory limit, however I tryied also to increase memory limit with ini_set('memory_limit', '128M') but also still the same problem.

Just in case you are curious, this is my php file code:

ini_set('memory_limit', '128M');
	header('Content-Type: text/plain; charset=UTF-8');
	ini_set('mssql.charset', 'UTF-8');
	ini_set('output_buffering',10000);
   session_start();
   @include('incl/config.php');
   @include('incl/connecta_bd.php');

	$codigo_cliente = 33255; //(float)$_POST['codigo_cliente'];

	$strSQL_cagendas = 'SELECT CONVERT(VARCHAR,a.fecha,103),   
	         CASE WHEN CONVERT(VARCHAR,a.hora,108) = \'00:00:00\' THEN \'\' ELSE CONVERT(VARCHAR,a.hora,108) END,
	         f.nombre_corto,   
			 pi.prest_item_desc,   
	         s.servicio,   
			 \'CITADA\',
	         CONVERT(VARCHAR,a.fecha_emision,103),  
			 a.n_solic,
			a.fecha+a.hora 
	    FROM cagendas a,   
	         cex_referencia cex_r,   
	         fpersona f,   
	         servicios s,   
	         prest_item pi 
	   WHERE cex_r.n_solic = a.n_solic and  
	         f.codigo_personal = a.codigo_personal and  
	         s.codigo_servicio = a.codigo_servicio and  
	         a.prest_item_pk = pi.prest_item_pk and  
	         a.fecha >= GetDate() AND  
	         a.codigo_cliente = ' . $codigo_cliente . ' AND  
	         a.cod_estado = \'CI\'';    
	
	$strSQL_lespera = 'SELECT 	            
	         CONVERT(VARCHAR,l.fecha_deseada,103),
			 \'BÚSTIA\',
			 f.nombre_corto,   
	         pi.prest_item_desc,   
			 s.servicio,
			 \'\',   
			 CONVERT(VARCHAR,l.fecha_ent_lista,103),  
	         l.cod_lespera_pk,
			 l.fecha_deseada  
		FROM lespera l,   
	         fpersona f,   
	         servicios s,   
	         prest_item pi  
	   WHERE f.codigo_personal = l.codigo_personal and  
	         s.codigo_servicio = l.codigo_servicio and  
	         pi.prest_item_pk = l.prest_item_pk and  
	         l.codigo_cliente = ' . $codigo_cliente . ' AND  
	         l.fecha_sal_lista is null AND  
	         l.tipo_episodio_pk in (2,3,13)';
	
	$strSQL_lei = 'SELECT CONVERT(VARCHAR,l.data_inclussio,103),   
	         \'\',
			 \'LLISTA ESPERA QUIRURGICA\',  
	         c.descripcio,
	         s.servicio,   
			 \'CITADA\',
			 CONVERT(VARCHAR,l.data_inclussio,103),
			 l.registre,
			l.data_inclussio
	    FROM pius_lei_llista l,   
	         pius_lei_codis_llista c,   
	         pius_lei_icd icd,   
	         servicios s  
	   WHERE c.codi_llista = icd.codi_llista and  
	         l.procediment_1 = icd.icd_pk and  
	         l.servei = s.codigo_servicio and  
	         l.historia = ' . $codigo_cliente . ' AND  
	         l.data_mb is null';
	
	$strSQL_lei_g = 'SELECT CONVERT(VARCHAR,l.data_inclussio,103),   
			 \'\',
			 \'PROGRAMACIÓ D\'\'ASSISTÈNCIA\',
	         l.proc_1_literal, 
			 s.servicio,
			 \'\',
			 CONVERT(VARCHAR,l.data_inclussio,103),
			 l.cod_pk_lei_gap,
			 l.data_inclussio   
	    FROM pius_lei_llista_gap l,   
	         servicios s
	   WHERE l.codigo_servicio = s.codigo_servicio and  
	         l.historia = ' . $codigo_cliente . ' AND  
	         l.situacio <> 2';
	
	$strSQL = 
	$strSQL_cagendas .
/***** If I comment this, or whatever other UNION, then php file works fine
	' UNION ' .
	$strSQL_lespera .
*/	' UNION ' . $strSQL_lei .
	' UNION ' . $strSQL_lei_g .
	' ORDER BY 9';
	echo $strSQL;
	$query = @mssql_query($strSQL, $cn) or die("ERROR: Error obtenint l'activitat pendent.");
	$n = @mssql_num_rows($query);
?>
<h2>Activitat pendent</h2>
<?php 
	if ($n) {
?>
<table>
	<thead>
		<tr>
			<th>Data</th>
			<th>Hora</th>
			<th>Agenda</th>
			<th>Prestaci&oacute;</th>
			<th>Servei</th>
			<th>Estat</th>
			<th>Entrada</th>
			<th>Refer&egrave;ncia</th>
		</tr>
	</thead>
<?php 
		for ($i=0; $i<$n; $i++){
			$data_h = htmlentities(mssql_result($query,$i,0),ENT_QUOTES,'UTF-8'); //cp1252
			$hora_h = htmlentities(mssql_result($query,$i,1),ENT_QUOTES,'UTF-8');
			$agenda_h = htmlentities(mssql_result($query,$i,2),ENT_QUOTES,'UTF-8');
			$prestacio_h = htmlentities(mssql_result($query,$i,3),ENT_QUOTES,'UTF-8');
			$servei_h = htmlentities(mssql_result($query,$i,4),ENT_QUOTES,'UTF-8');
			$estat_h = htmlentities(mssql_result($query,$i,5),ENT_QUOTES,'UTF-8');
			$entrada_h = htmlentities(mssql_result($query,$i,6),ENT_QUOTES,'UTF-8');
			$referencia_h = htmlentities(mssql_result($query,$i,7),ENT_QUOTES,'UTF-8');
			if (($i%2)==0)
				$classe='parell';
			else
				$classe='imparell';
?>
		<tr class="<?php echo $classe; ?>">
			<td><?php echo $data_h; ?></td>
			<td><?php echo $hora_h; ?></td>
			<td><?php echo $agenda_h; ?></td>
			<td><?php echo $prestacio_h; ?></td>
			<td><?php echo $servei_h; ?></td>
			<td><?php echo $estat_h; ?></td>
			<td><?php echo $entrada_h; ?></td>
			<td><?php echo $referencia_h; ?></td>
		</tr>
<?php 
		} // fi del for
?>
		</table>
<?php 
	} // end if
	else {
?>
<p class="no_activitat">Aquest pacient no t&eacute; activitat pendent</p>
<?php } // Fi de l'else ?>

Open in new window

0
 
gplanaAuthor Commented:
Tryied also to change UNION by UNION ALL, but the same problem again.
0
 
gplanaAuthor Commented:
I have to say the amount of data is not very large (in fact on my test just 4 records should be returned in total).
0
 
COBOLdinosaurCommented:
It maybe that mysql has a memory issue.  you should explain the query to see how much it has to hold in memory to work through all the logic.  To do the unions it has to hold all possibilities in memory until they are found to not be required, and it can't do that until the very end of the query.

Cd&
0
 
gplanaAuthor Commented:
but this query returns just few records (4 records on the example I'm testing).

Maybe there is a limitation on the string passed on query parameter of mssql_query function?
I know it's not a limitation of SQL-Server as if I comment the mssql_query line and echo the $strSQL variable then I copy the contents of this variable to SQL-Query analyzer and it works perfectly.

Maybe there is a parameter that limits the size of query parameter on mssql_query?
0
 
gplanaAuthor Commented:
I found the issue. The problem was query had some characters in UTF-8 encoding. I make a utf8_decode over the sql variable and now all works fine.
0
 
gplanaAuthor Commented:
I found the solution for my own.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 10
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now