MOD EDIT: Post moved to new thread; original thread: While loop causing an undefined offset
I'm having the same trouble. This code worked yesterday, but not today.
$host="localhost";
$user="root";
$password="Top Secret";
$Dbname = "calls_to_dispatch";
$mysqli = new mysqli($host, $user, $password, $Dbname) or die('host doesnt work ' . $mysqli->error);
if ($mysqli->connect_errno) {
echo "Hey you dolt, Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$WorkDate = $_SESSION['WorkDate'];
$Quest = "SELECT WorkDate FROM in_time_appts";
$stmt = $mysqli->prepare($Quest) or die('stat '.$mysqli->error);
$stmt->execute();
$DateResult = $stmt->get_result();
while ($row = mysqli_fetch_array($DateResult));
{
$TestWorkDate = $row['WorkDate']; //Now, nothing is passed from the row.
if ($TestWorkDate == $WorkDate) $Trap = 1;
}
echo $TestWorkDate . ' a ' . $WorkDate . '<br>';
Then This:
$InputPath = "TOA/";
$try = glob($InputPath . 'In Time_Late_Early appointments*.csv');
foreach ($try as $ImportFile)
{
$ReadFile = fopen($ImportFile, "r") or die("You dope, this file is unreachable");
$OutString[0] = $ImportFile;
fputcsv($ReadFile, $OutString);
echo $ImportFile . ' <br>';
while (($LineArray = fgetcsv($ReadFile, 1000, ",")) !== FALSE)
{
//////Below here/////
if (!stripos($LineArray[0], 'Prov', 0))
{
$BBT = $LineArray[0];
$NumAppts = $LineArray[1];
$InTime = $LineArray[2];
$Late = $LineArray[3];
$Early = $LineArray[4];
$NotStarted = $LineArray[5];
$Cancelled = $LineArray[6];
$BBTArray = explode("-", $BBT);
$TechNum = $BBTArray[0];
$NameArray = explode(" ", $Name); // Undefined variable
$FirstName = $NameArray[0];
$LastName = $NameArray[1]; // Undefined offset 1
if ($Trap != 1) // Undefined variable
{
$Quest = ("INSERT INTO in_time_appts
(WorkDate,
TechNum,
FirstName,
LastName,
SubSystem,
NumAppts,
InTime,
Late,
Early,
NotStarted,
Cancelled
)
VALUES ('$WorkDate',
'$TechNum',
'$FirstName',
'$LastName',
'$SubSystem', // Undefined variable
'$NumAppts',
'$InTime',
'$Late',
'$Early',
'$NotStarted',
'$Cancelled'
)") or die("'cant insert' . $mysqli->error");
$mysqli->query($Quest);
This script worked just fine yesterday when I shut the computer down last night.