Link to home
Start Free TrialLog in
Avatar of gplana
gplanaFlag for Spain

asked on

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.
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Can you show the code you're using and the exact error message you get, please?
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&
Avatar of gplana

ASKER

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.
Avatar of gplana

ASKER

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

Cd&
Avatar of gplana

ASKER

I suspect is a character encoding issue. Could it be?
Avatar of gplana

ASKER

Looking at logs, the error I'm getting are: zend_mm_heap_corrupted.
Try to increment the value of output_buffering in php.ini
Avatar of gplana

ASKER

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

Avatar of gplana

ASKER

Tryied also to change UNION by UNION ALL, but the same problem again.
Avatar of gplana

ASKER

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).
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&
Avatar of gplana

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of gplana
gplana
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gplana

ASKER

I found the solution for my own.