Fixes to prevent php warnings about trying to access array offset on null

This commit is contained in:
2026-02-24 09:50:05 -05:00
parent 1480feecf0
commit b201ac6d24

View File

@@ -764,6 +764,7 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["techname"]; $name = $currentvalues["techname"];
$pass = $passconf = "password_is_unchanged"; $pass = $passconf = "password_is_unchanged";
$shift = $currentvalues["shift"]; $shift = $currentvalues["shift"];
@@ -777,6 +778,13 @@ switch ($table) {
} else { } else {
$activetag = "<input type=\"checkbox\" name=\"active\">"; $activetag = "<input type=\"checkbox\" name=\"active\">";
} }
} else {
$name = NULL;
$pass = NULL;
$shift = NULL;
$admintag = "<input type=\"checkbox\" name=\"admin\">";
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else { } else {
// set form options for add // set form options for add
$sectiontitle = "<b>Add New Tech</b><br><br>"; $sectiontitle = "<b>Add New Tech</b><br><br>";
@@ -878,12 +886,17 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["shiftname"]; $name = $currentvalues["shiftname"];
if ($currentvalues["status"] == 1) { if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>"; $activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else { } else {
$activetag = "<input type=\"checkbox\" name=\"active\">"; $activetag = "<input type=\"checkbox\" name=\"active\">";
} }
} else {
$name = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else { } else {
// set form options for add // set form options for add
$sectiontitle = "<b>Add New Shift</b><br><br>"; $sectiontitle = "<b>Add New Shift</b><br><br>";
@@ -952,12 +965,17 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["subjectname"]; $name = $currentvalues["subjectname"];
if ($currentvalues["status"] == 1) { if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>"; $activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else { } else {
$activetag = "<input type=\"checkbox\" name=\"active\">"; $activetag = "<input type=\"checkbox\" name=\"active\">";
} }
} else {
$name = "";
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else { } else {
// set form options for add // set form options for add
$sectiontitle = "<b>Add New Subject</b><br><br>"; $sectiontitle = "<b>Add New Subject</b><br><br>";
@@ -1026,6 +1044,7 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["displaytxt"]; $name = $currentvalues["displaytxt"];
$priority = $currentvalues["linkpriority"]; $priority = $currentvalues["linkpriority"];
$url = $currentvalues["urltxt"]; $url = $currentvalues["urltxt"];
@@ -1034,6 +1053,12 @@ switch ($table) {
} else { } else {
$activetag = "<input type=\"checkbox\" name=\"active\">"; $activetag = "<input type=\"checkbox\" name=\"active\">";
} }
} else {
$name = NULL;
$priority = NULL;
$url = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
// determine where we are in the priority stack // determine where we are in the priority stack
$prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links")); $prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links"));
if ($prow["highest"] == $priority) { if ($prow["highest"] == $priority) {
@@ -1145,10 +1170,22 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["flagname"]; $name = $currentvalues["flagname"];
$flagsym = $currentvalues["flagsym"]; $flagsym = $currentvalues["flagsym"];
$flagcolor = $currentvalues["flagcolor"]; $flagcolor = $currentvalues["flagcolor"];
$flagcoloropts = ""; $flagcoloropts = "";
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$flagsym = NULL;
$flagcolor = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
foreach ($basic_colors as $cname => $chex) { foreach ($basic_colors as $cname => $chex) {
if ($chex == $flagcolor) { if ($chex == $flagcolor) {
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\" selected>$cname</option>"; $flagcoloropts = $flagcoloropts . "<option value=\"$chex\" selected>$cname</option>";
@@ -1156,11 +1193,6 @@ switch ($table) {
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\">$cname</option>"; $flagcoloropts = $flagcoloropts . "<option value=\"$chex\">$cname</option>";
} }
} }
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else { } else {
// set form options for add // set form options for add
$sectiontitle = "<b>Add New Flag</b><br><br>"; $sectiontitle = "<b>Add New Flag</b><br><br>";
@@ -1246,12 +1278,17 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["lpactionname"]; $name = $currentvalues["lpactionname"];
if ($currentvalues["status"] == 1) { if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>"; $activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else { } else {
$activetag = "<input type=\"checkbox\" name=\"active\">"; $activetag = "<input type=\"checkbox\" name=\"active\">";
} }
} else {
$name = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else { } else {
// set form options for add // set form options for add
$sectiontitle = "<b>Add New Part Action</b><br><br>"; $sectiontitle = "<b>Add New Part Action</b><br><br>";
@@ -1320,9 +1357,15 @@ switch ($table) {
"; ";
// pull current values from database // pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id")); $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id"));
if (!empty($currentvalues)) {
$name = $currentvalues["bannername"]; $name = $currentvalues["bannername"];
$bnrcolor = $currentvalues["bannercolor"]; $bnrcolor = $currentvalues["bannercolor"];
$bnrtextcolor = $currentvalues["textcolor"]; $bnrtextcolor = $currentvalues["textcolor"];
} else {
$name = NULL;
$bnrcolor = NULL;
$bnrtextcolor = NULL;
}
$bnrcoloropts = ""; $bnrcoloropts = "";
foreach ($basic_colors as $cname => $chex) { foreach ($basic_colors as $cname => $chex) {
if ($chex == $bnrcolor) { if ($chex == $bnrcolor) {