Does not work: Waiting for localhost

Topics: Developer Forum
Jul 23, 2013 at 9:46 PM
and waiting and waiting and ... well, you get the idea. I cobbled these two scripts from 05featuredemo. When 'MonthlyReport.php' launches, the wheels keep spinning and spinning. I have the time limit set to four minutes and that is reached almost every time. Here's the code:

MonthlyReport.php
<?php
session_name("PassTech");
session_start();
set_time_limit (480);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

//error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);  

gc_enable(); // Enable Garbage Collector
var_dump(gc_enabled()); // true
var_dump(gc_collect_cycles()); // # of elements cleaned up
gc_disable(); // Disable Garbage Collecto

ob_end_clean();

$BeginTime = date('H:i:s');
echo $BeginTime;

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

$SystemNum = $_SESSION['SystemNum'];

for($Joe = 0; $Joe <= 75; $Joe++) { 
    if ($SystemNum == 0) {
        $SystemNumEntry = $Joe;
    }
    
    else $SystemNumEntry = $System;
    echo '<br>Joe is here<br>' . $Joe . '<br><br>';
    
    $_SESSION['SystemNumEntry'] = $SystemNumEntry;

include "ImportCSV.php";


    
        echo '<br><br>' . $SystemNum . ' xx ' . $SystemNumEntry . '<br><br>';



$WriteFile = $_SESSION['FileName'];
$Path = '/Users/tim/Sites/classes/MonthlyReports/';
$FileOut = $Path . $WriteFile;

echo $FileOut . '<br><br>';

/** Include PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';


// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);



$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

$objWriter->save($FileOut, __FILE__);






//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
//$objWriter->save($destination);




$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;

echo date('H:i:s') , " File written to " , $FileOut, pathinfo(__FILE__, PATHINFO_BASENAME) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
//$JustPeachey = str_replace('.php', '.xlsx', __FILE__);

}
die ('wrote 2007');
ImportCSV.php:
<?php

set_time_limit (480);

// error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);  



//session_name("PassTech");
//session_start();


// set_time_limit (360);
//gc_enable(); // Enable Garbage Collector
//var_dump(gc_enabled()); // true
//var_dump(gc_collect_cycles()); // # of elements cleaned up
//gc_disable(); // Disable Garbage Collecto

//ob_end_clean();


//error_reporting(E_ALL);

ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);

set_include_path('/Users/tim/Sites/');




ini_set('memory_limit', '-1');
$GrandWorkOrders = 0;
$GrandCallCount = 0;

$host="localhost";
$user="root";
$password="g1G3m#1989";
$Dbname = "calls_to_dispatch";

$mysqli = new mysqli($host, $user, $password, $Dbname);

// Check connection
if ($mysqli->connect_errno) {
    echo "Hey dope!  Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}




$LastDate = $_SESSION['LastDate'];
$TechNumEntry = $_SESSION['TechNum'];
$SystemNum = $_SESSION['SystemNum'];
$SystemNumEntry = $_SESSION['SystemNumEntry'];


echo $SystemNum . '<br><br>';
$iRow = 1;


    $LastDateArray = explode("-", $LastDate);
        
        $EndMonth = $LastDateArray[0];
        $EndDay = $LastDateArray[1];
        $EndYear = $LastDateArray[2];
        
        $EndDate = $EndYear . '-' . $EndMonth . '-' . $EndDay;






    $NumMonth = cal_days_in_month(CAL_GREGORIAN, $EndMonth, $EndYear);

                $date = date_create($EndDate);
                   

                    $CommonEndDate = date_format($date, "M d, Y");
                    $EndMO = date_format($date, 'F, Y');
                    $FileMonth = date_format($date, 'm-Y');
                    
                date_sub($date, date_interval_create_from_date_string($NumMonth - 1 . 'days'));
                $StartDate = $EndYear . '-' . $EndMonth . '-01';


                $date = date_create($StartDate);
                    $StartDate = date_format($date, 'Y-m-d');
                    $CommonStartDate = date_format($date, "M d, Y");
                    
    
        for ($counter=0; $counter < $NumMonth; $counter++)
            {
                $date = date_create($StartDate);
                date_add($date, date_interval_create_from_date_string($counter . 'days'));
                
                $W[$counter] = date_format($date, "D");
                $D[$counter] = date_format($date, "n-j");
                

            }
            



/** Include PHPExcel */
require_once dirname(__FILE__) . '/PHPExcel.php';




// Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel();



// Set document properties
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Timothy Stringer")
                             ->setLastModifiedBy("Mac the Knife")
                             ->setTitle("Office 2007 XLSX Test Document")
                             ->setSubject("Office 2007 XLSX Test Document")
                             ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
                             ->setKeywords("office 2007 openxml php")
                             ->setCategory("Test result file");
                             
                             





                
                ####open folder 



                

// Create a first sheet, representing sales data
echo date('H:i:s') , " Add some data" , EOL;



//set header
$stmt = $mysqli->prepare("SELECT IdNum FROM TOAWorkOrdersNew WHERE WorkDate = ? AND TechNum = ?"); 
$stmt2 = $mysqli->prepare("SELECT IdNum FROM CallVolume WHERE WorkDate = ? AND ANI = ?"); 

$stmt->bind_param('ss', $IncDate, $TechNum); 
$stmt2->bind_param('ss', $IncDate, $CellNum); 

        
if ($SystemNumEntry == 0) $Quest = "SELECT * FROM Systems";
else $Quest = "SELECT * FROM Systems WHERE SystemNum = $SystemNumEntry";

$SystemResult = $mysqli->query($Quest) or die('Dipstick  can not query');
        {
         while ($row = $SystemResult->fetch_assoc()) 
                {
        //      $SystemNum = $row["SystemNum"];
                $System = $row["System"];
                $LongSystem = $row["LongSystem"];
                $Contractor = $row["Contractor"];


                
                $iRow = 1;

                $EndCol = 'A'. chr($NumMonth+43);
                $strRow = 'A' . $iRow  . ':' . $EndCol . $iRow;
                
                $fontRow = 'A' . $iRow;
                
                $ColorRow = 'A' . $iRow  . ':' . $EndCol . ($iRow+1);

                
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $iRow, $LongSystem);
    
                $objPHPExcel->getActiveSheet()->mergeCells($strRow);
                $objPHPExcel->getActiveSheet()->getStyle($strRow)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
                $objPHPExcel->getActiveSheet()->getStyle($strRow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                
                $objPHPExcel->getActiveSheet()->getStyle($strRow)->getFont()->setSize(20);
            $objPHPExcel->getActiveSheet()->getStyle($strRow)->getFont()->setName('Arial');
            $objPHPExcel->getActiveSheet()->getStyle($strRow)->getFont()->setBold(true);





$iRow++;
    $strRow = 'A' . $iRow  . ':' . $EndCol . $iRow;
    $ColorRow = 'A' . $iRow  . ':' . $EndCol . ($iRow+1);
    $fontRow = 'A' . $iRow;

    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $iRow, $EndMO);
    $objPHPExcel->getActiveSheet()->getStyle($ColorRow)->getFont()->setSize(18);
            $objPHPExcel->getActiveSheet()->getStyle($ColorRow)->getFont()->setName('Arial');
            $objPHPExcel->getActiveSheet()->getStyle($ColorRow)->getFont()->setBold(true);
    
                
    $iRow = $iRow + 2;
        $ColorRow = 'A' . ($iRow + 1)  . ':' . $EndCol . ($iRow+2);
    $objPHPExcel->getActiveSheet()->getStyle($ColorRow)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
    $objPHPExcel->getActiveSheet()->getStyle($ColorRow)->getFill()->getStartColor()->setARGB('DC2E25');
    
            
                
    
        $objPHPExcel->getActiveSheet()->mergeCells($strRow);
        $objPHPExcel->getActiveSheet()->getStyle($strRow)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle($strRow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle($fontRow)->getFont()->setSize(14);

$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $iRow+2, 'Tech Number');
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $iRow+2, 'Name');


$iRow++;

$fontRow = 'A' . $iRow;



        for ($counter = 0; $counter < $NumMonth; $counter++)
            {

            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($counter + 3, $iRow, $W[$counter]);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(($counter  + 3), $iRow, $D[$counter]);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($counter + 3, $iRow + 1, $W[$counter]);
            }
            
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($counter + 3, $iRow + 1, 'Calls');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($counter + 4, $iRow, 'Work');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAnd
I have put die traps and time traps, but I can't find where the scripts are hanging up.

Help?

tim

'If builders built buildings like programmers write programs, the first woodpecker to come along would wreck civilization."
Jul 23, 2013 at 9:51 PM
details, details, details.


MacBook Pro, OS 10.8.4, 2 GB RAM, 160 GB HD
PHP v 5.3.15
MySQL 5.7.1-m11
Apache 2.2.22