Call to a member function get() on null

I am testing the new version and i am getting a lot of errors and many questions and am sure others do as well.

first i get this error :

Fatal error: Uncaught Error: Call to a member function get() on null in C:\xampp\htdocs\all\t2021\src\phpfn.php:122 Stack trace: #0 C:\xampp\htdocs\all\t2021\src\phpfn.php(1355): PHPMaker2021_1692015\Container(‘sqllogger’) #1 C:\xampp\htdocs\all\t2021\src\phpfn.php(1268): PHPMaker2021_1692015\ConnectDb(Array) #2 C:\xampp\htdocs\all\t2021\src\phpfn.php(5471): PHPMaker2021_1692015\Conn() #3 C:\xampp\htdocs\all\t2021\src\phpfn.php(5625): PHPMaker2021_1692015\ExecuteQuery(’ SELECT COUNT(…‘, NULL) #4 C:\xampp\htdocs\all\t2021\src\userfn.php(511): PHPMaker2021_1692015\ExecuteScalar(’ SELECT COUNT(…') #5 C:\xampp\htdocs\all\t2021\index.php(28): require_once(‘C:\xampp\htdocs…’) #6 {main} thrown in C:\xampp\htdocs\all\t2021\src\phpfn.php on line 122

then somehow not sure i managed to bypass that error and i got below:
when i login i get this error : C:\xampp\htdocs\all\t2021\src\AdvancedSecurity.php(507): Call to undefined method PHPMaker2021_1692015\Profile::assign()

maybe it is related to above, the sessions saved on User_Validated are not recognized/undefined when used on Recordset_selecting .

also i have one question, on the server events when dose the session starts and can be used?

in addition, i noticed that the log file is actually logging the password typed into the text file even so i have selected hashed password and i think this is not secure and should be changed.

any help would be appreciated.

Be reminded that the database layer has been changed, see Migrating to v2021: https://phpmaker.dev/doc/migrate2021.htm.

If you have server side code querying the database in your server events, you MAY need to update it.

In the error messages:

C:\xampp\htdocs\all\t2021\src\phpfn.php:122
C:\xampp\htdocs\all\t2021\src\userfn.php(511)

Post your code near line 511 in userfn.php (which contains code from your the server side Global Code) and also near line 122 from C:\xampp\htdocs\all\t2021\src\phpfn.php.

Webmaster wrote:

Post your code near line 511 in userfn.php (which contains code from your the server side Global Code) and also near line 122 from C:\xampp\htdocs\all\t2021\src\phpfn.php.

the line 511 is on global code (i am counting some records here and out put them on the menu rendering to show the numbers of records and save them on session):
$UID=CurrentUserID();
if (CurrentUserLevel() <> -1 && CurrentUserLevel() <> 61 && CurrentUserLevel() <> 16) {
$foo = $myCount1 = ExecuteScalar(" SELECT COUNT() FROM deapproval WHERE ContractHolder=‘$UID’ " );
$foo[] = $myCount2 = ExecuteScalar(" SELECT COUNT(
) FROM prbhapproval WHERE UserID=‘$UID’ " );
$foo = $myCount3 = ExecuteScalar(" SELECT COUNT() FROM prubghapproval WHERE UserID=‘$UID’ " );
$foo[] = $myCount4 = ExecuteScalar(" SELECT COUNT(
) FROM executive1pr WHERE UserID=‘$UID’ " );
$foo = $myCount5 = ExecuteScalar(" SELECT COUNT() FROM orderchapproval WHERE ContractHolder=‘$UID’ “);
$foo[] = $myCount6 = ExecuteScalar(” SELECT COUNT(
) FROM orderbghapproval WHERE UserID=‘$UID’ " );
$foo = $myCount7 = ExecuteScalar(" SELECT COUNT() FROM orderubghapproval WHERE UserID=‘$UID’ " );
$foo[] = $myCount8 = ExecuteScalar(" SELECT COUNT(
) FROM executive1orders WHERE UserID=‘$UID’ " );
$foo = $myCount9 = ExecuteScalar(" SELECT COUNT(*) FROM executive2orders WHERE UserID=‘$UID’ " );

} else {
$foo = $myCount1 = ExecuteScalar(" SELECT COUNT() FROM deapproval " );
$foo[] = $myCount2 = ExecuteScalar(" SELECT COUNT(
) FROM prbhapproval " );
$foo = $myCount3 = ExecuteScalar(" SELECT COUNT() FROM prubghapproval " );
$foo[] = $myCount4 = ExecuteScalar(" SELECT COUNT(
) FROM executive1pr " );
$foo = $myCount5 = ExecuteScalar(" SELECT COUNT() FROM orderchapproval “);
$foo[] = $myCount6 = ExecuteScalar(” SELECT COUNT(
) FROM orderbghapproval " );
$foo = $myCount7 = ExecuteScalar(" SELECT COUNT() FROM orderubghapproval " );
$foo[] = $myCount8 = ExecuteScalar(" SELECT COUNT(
) FROM executive1orders " );
$foo = $myCount9 = ExecuteScalar(" SELECT COUNT(*) FROM executive2orders " );

}
$_SESSION[“alllist”]=array_sum($foo);
$_SESSION[“Count20”]=$myCount20= ExecuteScalar(" SELECT COUNT() FROM mprce " );
$_SESSION[“Count21”]=$myCount21= ExecuteScalar(" SELECT COUNT(
) FROM papproval " );
$_SESSION[“Count22”]=$myCount22= ExecuteScalar(" SELECT COUNT() FROM pcontractworkorderapp " );
$_SESSION[“Count23”]=$myCount23= ExecuteScalar(" SELECT COUNT(
) FROM costworkorder " );
$_SESSION[“Count24”]=$myCount24= ExecuteScalar(" SELECT COUNT(*) FROM mprscm " );


line 122 from

C:\xampp\htdocs\all\t2021\src\phpfn.php.

/**

  • Get Container
  • @return Psr\Container\ContainerInterface
    */
    function Container()
    {
    global $container;
    $numargs = func_num_args();
    if ($numargs == 1) { // Get
    return $container->get(func_get_arg(0));
    } elseif ($numargs == 2) { // Set
    $container->set(func_get_arg(0), func_get_arg(1));
    }
    return $container;
    }

If you check the error messages:

Fatal error: Uncaught Error: Call to a member function get() on null in C:\xampp\htdocs\all\t2021\src\phpfn.php:122
Stack trace:
#0 C:\xampp\htdocs\all\t2021\src\phpfn.php(1355): PHPMaker2021_1692015\Container(‘sqllogger’)
#1 C:\xampp\htdocs\all\t2021\src\phpfn.php(1268): PHPMaker2021_1692015\ConnectDb(Array)
#2 C:\xampp\htdocs\all\t2021\src\phpfn.php(5471): PHPMaker2021_1692015\Conn()
#3 C:\xampp\htdocs\all\t2021\src\phpfn.php(5625): PHPMaker2021_1692015\ExecuteQuery(’ SELECT COUNT(…‘, NULL)
#4 C:\xampp\htdocs\all\t2021\src\userfn.php(511): PHPMaker2021_1692015\ExecuteScalar(’ SELECT COUNT(
…')

You got the error when executing ExecuteScalar(). The script tried to get the SQL logger to log your SQL but failed to get the logger class. Be reminded the composer packages used in v2021 is very different from previous version. Make sure you have run composer update after generation and upload the “vendor” folder. You should do the follows:

  • Enable “Composer update” in Generate tab
  • Generate all files
  • Wait until the composer update completes
  • Upload all files in the project folder to your site again

sorry for replying late, i did follow all the steps you mentioned but still i get the same error. the only way forward is to delete the entire script in global code, however, this will lead to many other errors. and there is no log file.

Click Tools → Advanced Settings, enable Debug, generate the config.php again. Run your application again, by default the log file is under the “log” folder under your project folder. Again, make sure you re-generate all files and run composer update again, or there is no logger in the old “vendor” folder at all.