We help IT Professionals succeed at work.

php no error but execution stops

Desire2change
on
Medium Priority
2,711 Views
Last Modified: 2012-05-07
I have a program that reads xml files (7 at a time), each xml file is large and contains data of particular dates, i am running a loop in the following order
1) loop for 7 days a week
2) loop for the 7 xml files
3) the xml files are too deeply structured, i have retrieved them in an assoc array. now to go to particular fields , there is a nested loop of 12 x 50 ( it is necessary)

in the beginning of the script, i have :
ini_set('memory_limit', '256M');        
ini_set('max_input_time', 300);        
ini_set('max_execution_time', 3600);  
set_time_limit(3600);
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

After doing this also, my script doesn't execute completely, it stops in between and no error.
can anyone tell me what exactly is the problem, when i see view source , i see that the source is not executed completely, for some reason the script stops
any idea on why this might be happening ??
Comment
Watch Question

Commented:
to tell you in detail we would need to see the code you are running.

to get an idea yourself I would be putting in some echo "I am here" or  echo "Iteration $i" type debugging messages in your code in the looping sections. that way you can track down where execution is failing.

put the line:

    die( "got here");

a the top of your script. if you see "got here" in your browser window then simply move the

    die( "got here");
 
line further down in your code, save and then preview on front end again.

can take a while but will help you track down where the script is falling over in the absense of any error reports on screen.



    die( "got here");

Open in new window

Author

Commented:
it doesn't stop at a particular line,
at the top there is a loop of  7 ( 7 days as i explained earlier ) , if i run from 1 to 7 the execution stops when it reaches 5
if i run till 5 , the whole output is displayed perfectly, without problem.
but if it is a timeout problem, then why doesn't it show the fatal timeout error

Most Valuable Expert 2011
Author of the Year 2014

Commented:
Good question here: "but if it is a timeout problem, then why doesn't it show the fatal timeout error"

Probably it is NOT a timeout problem.  It is more likely to be a data-dependent logic error that causes an early exit from the program.  I suggest you use tracking messages, like basic612 suggested.  

Another way to look at this situation is to set the time limit to one second and see if you can get a timeout to occur (just loop a counter or something to use up a second of CPU time).  There is a very tiny possibility that your server or PHP installation is misconfigured in such a way that it suppresses the timeout error message.

Best regards, ~Ray

Author

Commented:
as I said, it works when i change the topmost loop from 1 to 7 , to 1 to 4
if it was logic problem , it will not work for any kind of loop right ?
Most Valuable Expert 2011
Author of the Year 2014

Commented:
"if it was logic problem , it will not work for any kind of loop right ?"  Well, that depends on what you do in the loop.  If you can post the code, perhaps there is something we might spot, or a more concrete suggestion we might offer.

Author

Commented:
The code is too complex and I cannot paste the url here.
But for you to have an idea I am  just posting a part of the code.
Hope you are able to understand it.....
<div id="chaine_prog1">
            	<div id="loadingid" align="center"><img src="images/ajax-loader.gif" border="0" />
                </div>
				<script type="text/javascript">
						mynewarray=new Array();
					</script>
				<?php
				$xxr=0;
				//die($sunday. "====".$en);
				for($myday=$sunday ; $myday <= ($en-4) ; $myday++) 
				{
					$xxr++;
					$dt_mt = date('Y-m-d H:i:s', mktime($hour_mt[0],$hour_mt[1],0,$mnth, $myday, $year));	
					$dt_mf = date('Y-m-d H:i:s', mktime($hour_mf[0],$hour_mf[1],0,$mnth, $myday, $year));
					$dt_af = date('Y-m-d H:i:s', mktime($hour_af[0],$hour_af[1],1,$mnth, $myday, $year));
					$dt_at = date('Y-m-d H:i:s', mktime($hour_at[0],$hour_at[1],0,$mnth, $myday, $year));		
					$dt_ef = date('Y-m-d H:i:s', mktime($hour_ef[0],$hour_ef[1],1,$mnth, $myday, $year));
					$dt_et = date('Y-m-d H:i:s', mktime($hour_et[0],$hour_et[1],0,$mnth, $myday, $year));	
					$dt_nt = date('Y-m-d H:i:s', mktime($hour_nt[0],$hour_nt[1],0,$mnth, $myday+1, $year));
					$dt_pf = date('Y-m-d H:i:s', mktime($hour_pf[0],$hour_pf[1],1,$mnth, $myday, $year));
					$dt_pt = date('Y-m-d H:i:s', mktime($hour_pt[0],$hour_pt[1],0,$mnth, $myday, $year));
					$dt_nf = date('Y-m-d H:i:s', mktime($hour_nf[0],$hour_nf[1],1,$mnth, $myday, $year));
					
					$fromdate=$dt_mf;
					$todate=$dt_nt;
 
					
				?>
				
                <div id="onewholechineprog<?=$xxr?>" style="display:none;">
					
					<?php
                    $chstr = $cstr;
					$chstr="SELECT * FROM `chaine` WHERE publish='Y' AND kind=1 AND cid IN (".$groupName1.") ORDER BY cid DESC ";
					$chres=mysql_query($chstr);
					$chaine = 1;
					while($data = mysql_fetch_assoc($chres)) {
						$cid = $data["cid"];
						$title = $data['title'];
						$xmlName = $data['xmlname'].".XML";
						if(isset($xmlName) && strlen($xmlName) >0) {
						
						?>
						
						 <!-- déb chaine_prog_<?=$chaine?> -->
    				<div id="chaine_prog">
      					<div class="chaine_logo">
                       		<a href="tvchannel_details.php?cid=<?=$data["cid"]?>" ><img src="images/logo_chaine/<?=$data["logo"]?>" width="89" height="56" border="0" /></a>
                        </div>
    					
						
						<div id="screen<?=$chaine?><?=$xxr?>" class="screen"> <img class="prev" src="images/arrow-left.png" alt="prev" width="20" height="60" />
                <div class="sections" id="section<?=$chaine?><?=$xxr?>">
                  <ul>
						
			       				<script>
									mynewarray["mySlides<?=$chaine?><?=$xxr?>"]=new Array();
								</script>
          						<?				
								$myno=0;
								$tmp=1;
								$tgmp=0;
								$matin=0;
								$smidi=0;
								$butsoire=0;
								$soire=0;
								$nuit=0;
								$tmsn=0;						
							$xmlfile = 'xml/'.$xmlName;
							$assoc=xml_parse_into_assoc($xmlfile);
							$Arrayname = array();
							$k=0;
							$lim1=count($assoc[GRILLETV][JOURNEE]);
							for($jj=0; $jj<$lim1; $jj++) {	
								$lim2=count($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION]);
								for($i=0; $i<$lim2; $i++) {
									
									$title = mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][TITRE]); 
									$date =  mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][DATEHEURE]); 
									$duration = mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][DUREE]); 
									$subtitle = mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][SURTITRE]); 
									$csa = mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][CSA][NOMLONG]); 
									$letexte=mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][EMISSION][LESTEXTES][TEXTE][LETEXTE]); 
									if($letexte=='')
										$letexte=mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][EMISSION][MAGAZINEXY][LESTEXTES][TEXTE][LETEXTE]); 								
										$date = str_replace( 'T', ' ', $date);
										$datarr = explode(' ', $date);
										$dateOnly = $datarr[0];
										if(isset($title) && strlen($title) >0 && isset($date) &&  strlen($date) >0 && isset($duration) && strlen($duration) >0 && isset($dateOnly) && strlen($dateOnly) >0)
										{
										$from = strtotime($fromdate);
										$to = strtotime($todate);
										
										$title = stripslashes($title);
										$subtitle = stripslashes($subtitle);
										$prg_date = stripslashes($date);
										$duration = stripslashes($duration);
										$dateOnly = stripslashes($dateOnly);
										$csa = stripslashes($csa);
										$letexte = stripslashes($letexte);
										$prg_date_str = strtotime($prg_date);
										if(($from <= $prg_date_str)  &&  ($to >=  $prg_date_str) ) {
										
										$Arrayname[$k] = array('date' =>$prg_date, 'duration' => $duration, 'title' => $title , 'subtitle' => $subtitle , 'dateOnly' =>$dateOnly, 'csa' => $csa, 'letexte' => $letexte);
										$singleDetails=$Arrayname[$k];
									$k++;
					
					
					                 
									if($tmp == 4) 
									{ 
										$tmp = 1;
									}
									if($tmp==1)
									{
										//echo '<div>';
									}
									echo '<li>';
									$prog_date_xplode = explode(" ",$singleDetails["date"]);
									$time_xplode = explode(":",$prog_date_xplode[1]);
									$date_xplode = explode("-",$prog_date_xplode[0]);
									$d=date("l", mktime($time_xplode[0],$time_xplode[1],$time_xplode[3],$date_xplode[1], $date_xplode[2],$date_xplode[0]));
									$nd=date("F", mktime($time_xplode[0],$time_xplode[1],$time_xplode[3],$date_xplode[1], $date_xplode[2],$date_xplode[0]));
									if($tmp == 1){
										$title = htmlentities($singleDetails["title"], ENT_QUOTES, 'UTF-8');
										$tit=htmlentities($singleDetails["letexte"], ENT_QUOTES, 'UTF-8');
										?>
          						<div class="box-side">
                                <abbr href="#" title="<span class='title'><?=htmlentities(stripslashes($title))?></span><br><br><?=stripslashes($tit)?><br><br><?=stripslashes($singleDetails["csa"])?><br><?=$singleDetails["duration"]?> min<br><br><strong><?=$time_xplode[0].":".$time_xplode[1]?></strong>&nbsp;">
            <?
											$tmp++;
										}elseif($tmp == 2){
										
										$title = htmlentities($singleDetails["title"], ENT_QUOTES, 'UTF-8');
										$tit=htmlentities($singleDetails["letexte"], ENT_QUOTES, 'UTF-8');
						?>
            <div class="box-side"><abbr href="#" title="<span class='title'><?=htmlentities(stripslashes($title))?></span><br><br><?=stripslashes($tit)?><br><br><?=stripslashes($singleDetails["csa"])?><br><?=$singleDetails["duration"]?> min<br><br><strong><?=$time_xplode[0].":".$time_xplode[1]?></strong>&nbsp;">
              <?
											$tmp++;
										}else{
										
										$title = htmlentities($singleDetails["title"], ENT_QUOTES, 'UTF-8');
										$tit=htmlentities($singleDetails["letexte"], ENT_QUOTES, 'UTF-8');
										
										?>
              <div class="box-side"><abbr href="#" title="<span class='title'><?=htmlentities(stripslashes($title))?></span><br><br><?=stripslashes($tit)?><br><br><?=stripslashes($singleDetails["csa"])?><br><?=$singleDetails["duration"]?> min<br><br><strong><?=$time_xplode[0].":".$time_xplode[1]?></strong>&nbsp;">
                <?
											$tmp++;
										}
									?>
									
									
									<?=$jour[$d]?>
                                    &nbsp;
                                    <?=$date_xplode[2]?>
                                    &nbsp;
                                    <?=$mois[$nd]?>
                                    &nbsp;<strong>
                                    <?=$time_xplode[0].":".$time_xplode[1]?>
                                    </strong><br>
                                    <span class="title">
                                    <?=htmlentities($singleDetails["title"], ENT_QUOTES, 'UTF-8');?>
                                    </span><br><?=$singleDetails["csa"]?><br>
                                    <?=$singleDetails["duration"]?>
                                    min</abbr>
               					</div>
             					 <?
								//if($tmp == 4) {
								 //}
								 echo '</li>';
									
									for($imk=1;$imk<=12;$imk++){
										if(strtolower(trim(date("F", mktime(0, 0, 0, $imk, 1, 2009)))) == strtolower(trim($nd))){
											$monthnumber = $imk;
										}
									} 
								//$monthnumber++;
								$tm = date('Y-m-d H:i:s', mktime($time_xplode[0],$time_xplode[1],0,$monthnumber, $date_xplode[2], $year));
								/*echo "<hr>".$tm;
								echo "<hr>".$dt_af;
								echo "<hr>".$dt_at;*/
								if(strtotime($tm) >= strtotime($dt_mf) and strtotime($tm) <= strtotime($dt_mt) and $matin==0)
								{
									?>
									<script>
										mynewarray["mySlides<?=$chaine?><?=$xxr?>"][<?=$tmsn?>]=<?=$myno?>;
									</script>
									<?php
									$tmsn++;
									$matin++;
								}
 
								if(strtotime($tm) >= strtotime($dt_af) and strtotime($tm) <= strtotime($dt_at) and $smidi==0)
								{
								?>
								<script>
									mynewarray["mySlides<?=$chaine?><?=$xxr?>"][<?=$tmsn?>]=<?=$myno?>;
								</script>
								<?php
								$tmsn++;
								$smidi++;
								}
								if(strtotime($tm) >= strtotime($dt_ef) and strtotime($tm) <= strtotime($dt_et) and $butsoire==0)
								{
									?>
									<script>
										mynewarray["mySlides<?=$chaine?><?=$xxr?>"][<?=$tmsn?>]=<?=$myno?>;
									</script>
									<?php
									$tmsn++;
									$butsoire++;
								}
								if(strtotime($tm) >= strtotime($dt_pf) and strtotime($tm) <= strtotime($dt_pt) and $soire==0)
								{
									?>
									<script>
										mynewarray["mySlides<?=$chaine?><?=$xxr?>"][<?=$tmsn?>]=<?=$myno?>;
									</script>
									<?php
									$tmsn++;
									$soire++;
								}
 
								if(strtotime($tm) >= strtotime($dt_nf) and strtotime($tm) <= strtotime($dt_nt) and $nuit==0)
								{
									?>
									<script>
										mynewarray["mySlides<?=$chaine?><?=$xxr?>"][<?=$tmsn?>]=<?=$myno?>;
									</script>
									<?php
									$tmsn++;
									$nuit++;
								}
									$myno++;
								
								
												}
									}
								}
							}
						}
 
								
								//end for loop
								//if($tmp<4)
									//echo '</div>';
								?>
           
			 <!-- end panel -->
        		
		 			 </ul>
		   			
                   </div>
				    <img class="next" src="images/arrow-right.png" alt="prev" width="20" height="60" /></a>
                  </div>
				  </div>
                <!-- fin chaine_prog -->
                  
                <?
                            $chaine++;
                          
                                
            }//end while			
                    ?>
        
        
        </div>  <!-- finished div one whole chaine programme -->
		<?
		}
		?>

Open in new window

Most Valuable Expert 2011
Author of the Year 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.