Here's a script I have been working on for a while. The routine runs through the first iteration. However, on the 2nd time through, I get the above error. Here's the code:
<?php
header( 'Content-type: text/html; charset=utf-8' );
session_name("PassTech");
session_start();
set_time_limit (480);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$host="localhost";
$user="root";
$password="g****9";
$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;
}
if (!$_SESSION['StartTime']) $StartTime = time();
else $StartTime = $_SESSION['StartTime'];
$BeginTime = date('H:i:s', $StartTime);
echo $BeginTime;
ini_set('include_path', '/Users/tim/Sites/DispatchReports');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
$SystemNumEntry = $_SESSION['SystemNumEntry'];
echo '<br><br>' . $SystemNumEntry . ' ss ' . $SystemNum . '<br>';
if ($SystemNumEntry == 0) $Quest = "SELECT * FROM Systems";
else $Quest = "SELECT * FROM Systems WHERE SystemNum = '$SystemNumEntry'";
echo $Quest . '<br>';
$result = $mysqli->query($Quest);
while ($row = $result->fetch_assoc()) { //<---- Works the first go round. Dies at 2nd
$System = $row['System'];
$LongSystem = $row['LongSystem'];
$Contractor = $row['Contractor'];
if ($SystemNumEntry == 0) $SystemNum = $row['SystemNum'];
else $SystemNum = $SystemNumEntry;
echo $SystemNumEntry . ' qq ' . $SystemNum . ' mo ';
include "ImportCSV.php";
$WriteFile = $_SESSION['FileName'];
$Path = '../classes/MonthlyReports/';
$FileOut = $Path . $WriteFile;
/** Include PHPExcel_IOFactory */
require_once '../classes/PHPExcel/IOFactory.php';
// Save Excel 2007 file
if ($GrandCallCount > 0 || $GrandWorkOrders > 0) {
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save($FileOut, __FILE__);
echo $SystemNum . ' ' . $WriteFile . '<br>
<br>';
}
flush();
ob_flush();
echo $SystemNum . 'sysnym<br>';
}
$StopTime = time();
$ElapsedTime = $StopTime - $StartTime;
printf("Errormessage: %s\n", $mysqli->error) . '<br>';
echo 'stop ' . date('H:i:s', $ElapsedTime);
?>
The error trap doesn't return any.
Gotta be missing something obvious. I have stared at this routine most of the day and can't find the problem.