Solved

Problems accessing a php address depending of a post paramenter

Posted on 2013-11-09
15
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

729 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