Uncaught Error: Call to a member function phrase() on null

Good Evening all,I am using Dynamic user level security in project following the Phpmaker documentation, after generation, I getting the error, which I could not solve."Fatal error: Uncaught Error: Call to a member function phrase() on null in D:\XAMPP\htdocs\PROJECT1\src\AdvancedSecurity.php:688 …
{main} thrown in D:\XAMPP\htdocs\PROJECT1\src\AdvancedSecurity.php on line 688"Line no 688 have below code

  // Add Anonymous user level
    $conn = Conn(Config("USER_LEVEL_DBID"));
    if (!$this->AnoymousUserLevelChecked) {
        $sql = "SELECT COUNT(*) FROM " . Config("USER_LEVEL_TABLE") . " WHERE " . Config("USER_LEVEL_ID_FIELD") . " = -2";
        if (ExecuteScalar($sql, $conn) == 0) {
            $sql = "INSERT INTO " . Config("USER_LEVEL_TABLE") .
                " (" . Config("USER_LEVEL_ID_FIELD") . ", " . Config("USER_LEVEL_NAME_FIELD") . ") VALUES (-2, '" . AdjustSql($Language->phrase("UserAnonymous"), Config("USER_LEVEL_DBID")) . "')";
            $conn->executeStatement($sql);
        }
    }

I would be very thankful to your help/suggestions.
Thanks you to read it.

If you have added code in server event (e.g. global code), you might not have created the langauge object first. You should enable Debug and trace the source of the error.

It seems you’ve just changed your userlevels table that do not have the following three records.

If so, then make sure there are three following records inside:

  1. User_Level_ID = 0, User_Level_Name = Default
  2. User_Level_ID = -1, User_Level_Name = Administrator
  3. User_Level_ID = -2, User_Level_Name = Anonymous

Sir, Thanks to both of you for reply,Sir, I used below code in userfn.php (Global code) When I do not use below code this code it works website works excepting the below function return values, otherwise it create error as"display "Server can not handle request … 500"Kindly help me to know, where I am making mistakefunction wpmautofils($prm)
{
if($prm == “WH”) {
// Get Warehouse ID
$ei = CurrentUserID();
$wh = ExecuteRow(“SELECT eWarehouse FROM employees WHERE euUserLevel =$ei”);
$whr = $wh[“eWarehouse”];
return $whr;
}
elseif($prm == “DTM”) {
// Get current Month
$dtm = CurrentDate();
$dtmr = date(“F”,strtotime($dtm));
return $dtmr;
}
elseif($prm == “DTY”) {
// Get a Current year
$dty = CurrentDate();
$dtyr = date(“Y”,strtotime($dty));
return $dtyr;
}
}

How did you call that function? Can you post the related code for it?

Sir, this is the code where I call function in Row_inserting eventpublic function rowInserting($rsold, &$rsnew)
{
// Enter your code here
$rsnew[“iFinancialYear”] = wpmautofils(“FY”);
$rsnew[“iWarehouseID”] = wpmautofils(“WH”);
$rsnew[“iDateMonth”] = wpmautofils(“DTM”);
$rsnew[“iDateYear”] = wpmautofils(“DTY”);
}

Okay. Now let’s see this code:

$ei = CurrentUserID();
$wh = ExecuteRow("SELECT eWarehouse FROM employees WHERE euUserLevel =$ei");

You tried to assign the $ei variable with current user id, and then in the next row, you tried to assign the value of $ei to euUserLevel which I assumed it as user level field. If so, then you should change this code:$ei = CurrentUserID();to:$ei = CurrentUserLevel();and try again.

Sir, thank you very very much for help to solve this problem. I was struggling from 3 days, you solved it quickly.Thank very much again.