Solved

Problems accessing a php address depending of a post paramenter

Posted on 2013-11-09
15
314 Views
Last Modified: 2013-11-19
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
Comment
Question by:gplana
  • 10
  • 3
  • 2
15 Comments
 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
Can you show the code you're using and the exact error message you get, please?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
 
LVL 15

Author Comment

by:gplana
Comment Utility
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
 
LVL 15

Author Comment

by:gplana
Comment Utility
If I made an ajax call from jquery and access to the status attribute, I get a 0 as its value.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Then there is an error on the server and you should be able to see it in the error log.

Cd&
0
 
LVL 15

Author Comment

by:gplana
Comment Utility
I suspect is a character encoding issue. Could it be?
0
 
LVL 15

Author Comment

by:gplana
Comment Utility
Looking at logs, the error I'm getting are: zend_mm_heap_corrupted.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
Try to increment the value of output_buffering in php.ini
0
 
LVL 15

Author Comment

by:gplana
Comment Utility
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
 
LVL 15

Author Comment

by:gplana
Comment Utility
Tryied also to change UNION by UNION ALL, but the same problem again.
0
 
LVL 15

Author Comment

by:gplana
Comment Utility
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
 
LVL 15

Author Comment

by:gplana
Comment Utility
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
 
LVL 15

Accepted Solution

by:
gplana earned 0 total points
Comment Utility
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
 
LVL 15

Author Closing Comment

by:gplana
Comment Utility
I found the solution for my own.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now