I've built a web app that works perfectly in my development environment. In my production environment, however, I get notices that I cannot reproduce in my dev environment although I've set PHP to report all errors with 'error_reporting(E_ALL);' at the start of the page. eg,'Notice: Undefined index: name in /home/bontshit/public_html/admin/library/functions.php on line 202'. How can I track down the problem without simply muting the error reporting?
I'm using The AppServ Open Project - 8.6.0 for Windows Now you running on PHP 5.6.30; my production environment is on the same version of PHP. I've added the code the notice I mentioned refers to and clearly (I believe) the index 'name' was defined.
$categories = array();
while($row = dbFetchAssoc($result)) {
extract($row);
if ($cat_parent_id == 0) {
// we create a new array for each top level categories
$categories[$cat_id] = array('name' => $cat_name, 'children' => array());
} else {
// the child categories are put into the parent category's array
$categories[$cat_parent_id]['children'][] = array('id' => $cat_id, 'name' => $cat_name);
}
}
// build combo box options
$list = '';
foreach ($categories as $key => $value) {
$name = $value['name'];
$children = $value['children'];
$list .= "<option value=\"$key\"";
if ($key == $catId) {
$list.= " selected";
}
$list .= ">$name</option>\r\n";
foreach ($children as $child) {
$list .= "<option value=\"".$child['id']."\"";
if ($child['id'] == $catId) {
$list.= " selected";
}
$list .= "> ".$child['name']."</option>\r\n";
}
}