php no error but execution stops

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 ??
Desire2changeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

basic612Commented:
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

0
Desire2changeAuthor 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

0
Ray PaseurCommented:
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
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Desire2changeAuthor 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 ?
0
Ray PaseurCommented:
"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.
0
Desire2changeAuthor 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

0
Ray PaseurCommented:
@Desire2change: I think you hit the nail on the head with this statement: "The code is too complex."

There is ZERO chance I will be able to understand it.  You have n-dimensional arrays and no comments anywhere in sight.  Not trying to be rude to you, but I would fire a programmer who presented something like this.  

Some things you might want to consider (in addition to adding comments to the code)...

Avoid the use of the short_tags - programming that produces incompatibility with XML is not really a habit you want to develop.

Consider learning about Object-Oriented Programming.

Consider reducing the use of redundant and unnecessary functions and variables.  In the code snippet you will find a few lines extracted from the snippet posted above.  They are listed in the order they appear in the code.  It seems throughout the programming there are a lot of "non-value-added" structures that can be eliminated or revised in such a way that the overall execution time would go down dramatically.  For example, I found 22 occurrences of strtotime() - often repeated with the same variable.  Why not compute the timestamp once and store it?

I will sign off on this question now.  You need to put in some data and logic visualization structures, and we have shown you how to do that.  Best of luck with it, ~Ray
// COPY AND ESCAPE A VALUE INTO THE VARIABLE $date 
 $date = mysql_real_escape_string($assoc[GRILLETV][JOURNEE][$jj][DIFFUSION][$i][DATEHEURE]); 
 
// ELIMINATE THE LETTER 'T' FROM THE DATE - WHAT POSSIBLE USE IS THIS?
 $date = str_replace( 'T', ' ', $date);
 
// TEST TO SEE IF THE $date VARIABLE IS SET - IT HAS TO BE SET BECAUSE OF THE CODE THAT CAME BEFORE
 if(isset($title) && strlen($title) >0 && isset($date) && strlen($date) >0 && isset($duration) && strlen($duration) >0 && isset($dateOnly) && strlen($dateOnly) >0)
 
// COPY AND REMOVE THE ESCAPE CHARACTERS FROM THE VARIABLE $date
 $prg_date = stripslashes($date);
 
// MAKE A TIMESTAMP OUT OF THE COPIED DATE
 $prg_date_str = strtotime($prg_date);
 
// UNNECESSARY RECOMPUTATION USING strtotime()
if(strtotime($tm) >= strtotime($dt_ef) and strtotime($tm) <= strtotime($dt_et) and $butsoire==0)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.