Mysqli errors: Trying to access array offset on value of type bool. Fixed. Please...
[fa-stable.git] / gl / includes / db / gl_db_account_types.inc
index 76d41ede72281a29ecc44dce8aa9bcb2ee8e8d21..04fd9e9980288f96fdf83a062424f5fb1686b6b7 100644 (file)
@@ -22,7 +22,9 @@ function update_account_type($id, $name, $class_id, $parent, $old_id)
        begin_transaction();
        if ($old_id !== $id)
        {
-               $sql = "SELECT id FROM ".TB_PREF."chart_types WHERE parent = ".db_escape($old_id);
+               $sql = "SELECT id 
+                       FROM ".TB_PREF."chart_types 
+                       WHERE parent = ".db_escape($old_id);
 
                $result = db_query($sql, "could not get account type");
 
@@ -32,19 +34,23 @@ function update_account_type($id, $name, $class_id, $parent, $old_id)
                                ." WHERE id = '".$myrow['id']."'";
                        db_query($sql, "could not update account type");
                }
-               $sql = "SELECT account_code FROM ".TB_PREF."chart_master WHERE account_type = ".db_escape($old_id);
+               $sql = "SELECT account_code 
+                       FROM ".TB_PREF."chart_master 
+                       WHERE account_type = ".db_escape($old_id);
 
                $result = db_query($sql, "could not get account");
 
                while ($myrow = db_fetch($result))
                {
-               $sql = "UPDATE ".TB_PREF."chart_master SET account_type=".db_escape($id)
+               $sql = "UPDATE ".TB_PREF."chart_master 
+                       SET account_type=".db_escape($id)
                                ." WHERE account_code = '".$myrow['account_code']."'";
                        db_query($sql, "could not update account");
                }
        }
-    $sql = "UPDATE ".TB_PREF."chart_types SET id=".db_escape($id) .", name=".db_escape($name).",
-               class_id=".db_escape($class_id).", parent=".db_escape($parent)
+    $sql = "UPDATE ".TB_PREF."chart_types 
+               SET id=".db_escape($id) .", name=".db_escape($name).",
+                       class_id=".db_escape($class_id).", parent=".db_escape($parent)
                ." WHERE id = ".db_escape($old_id);
 
        $ret = db_query($sql, "could not update account type");
@@ -92,7 +98,7 @@ function get_account_type_name($id)
        $result = db_query($sql, "could not get account type");
 
        $row = db_fetch_row($result);
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 
 function delete_account_type($id)