Solved

Problems accessing a php address depending of a post paramenter

Posted on 2013-11-09
15
322 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 31

Expert Comment

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

Expert Comment

by:COBOLdinosaur
ID: 39635805
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
ID: 39635821
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 15

Author Comment

by:gplana
ID: 39635823
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
ID: 39635826
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
ID: 39635851
I suspect is a character encoding issue. Could it be?
0
 
LVL 15

Author Comment

by:gplana
ID: 39635858
Looking at logs, the error I'm getting are: zend_mm_heap_corrupted.
0
 
LVL 31

Expert Comment

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

Author Comment

by:gplana
ID: 39636055
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
ID: 39636058
Tryied also to change UNION by UNION ALL, but the same problem again.
0
 
LVL 15

Author Comment

by:gplana
ID: 39636059
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
ID: 39636323
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
ID: 39636330
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
ID: 39648714
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
ID: 39658841
I found the solution for my own.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php mysql check email already in database. (second check) 7 65
Add email address from a web page to outlook 2010 contacts ? 8 40
PHP Mail error 3 26
Wordpress Query 5 25
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
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.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 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