( ! ) Fatal error: Uncaught Error: Call to a member function get() on null in C:\wamp64\www\mws\src\phpfn.php on line 122
( ! ) Error: Call to a member function get() on null in C:\wamp64\www\mws\src\phpfn.php on line 122
I have checked but find no errors. The only thing is that I notice that unlike the 2020 version now in the golbal code it does not accept variables without function can it be?
phpfn.php
works fine
//Get active campaigns
function getActiveCamp(){
$ac = ExecuteScalar(“SELECT campagne.idCampagna FROM campagne WHERE campagne.Attiva = ‘1’”);//row 162
return $ac;
}
//Get all campaigns array
function getAllCamp(){
$alc = ExecuteRows(“SELECT idCampagna FROM campagne”);
$alc = implode(“,”, array_column($alc, “idCampagna”));
return $alc;
}
not works
//CurrentPageName() != “prospetto.php”
if (CurrentUserLevel() != -2){
//Get nome and status attiva campaing
$attiva = ExecuteRow(“SELECT idCampagna, Nome FROM campagne WHERE Attiva = ‘1’”);//row 175 error
//Get avvisi for menu bar
$status = ExecuteScalar(“SELECT COUNT(idTicket) FROM ticket WHERE Tipo = ‘2’ && Stato = ‘0’”);
}
In v2021, for the example above, CurrentPageName() will return “prospetto”. In other words, it will not include the .php (extension file) anymore. (See Migrating to v2021: https://phpmaker.dev/doc/migrate2021.htm)
Thanks
I will have to change them all however this was in comment.
I tried to set them as global but it doesn’t work. I call the variable in the header
userfn.php (Global Code)
if (CurrentUserLevel() != -2){
//Get send email/sms for menu bar
$GLOBALS[‘em’] = ExecuteScalar(“SELECT SUM(LENGTH(Users) - LENGTH(REPLACE(Users, ‘,’, ‘’)) + 1) FROM messages WHERE Tipo = ‘1’ || TIPO = ‘3’”);
}
I’ve tried in page_loading but not works
// Page Loading event
function Page_Loading() {
if (CurrentUserLevel() != -2){
$GLOBALS[‘em’] = ExecuteScalar(“SELECT SUM(LENGTH(Users) - LENGTH(REPLACE(Users, ‘,’, ‘’)) + 1) FROM messages WHERE Tipo = ‘1’ || TIPO = ‘3’”);
}
}
you can to doing in two ways:
Put the non function codes in Page_Loading and try again. Note that you need to define the global variables first in global codes then use $GLOBALS[“var”] to set up the variables.
in Global Codes:
$var = “”; // Define global variable
in Page_Loading:
global $var;
$var = ExecuteScalar(…);
in Global Codes:
function MyFunction() {
$var = ExecuteScalar(…);
return $var;
};
In your header/footer ecc
echo MyFunction()//if string
echo MyFunction()[‘arraykey’]//if array
you can to doing in two ways:
Put the non function codes in Page_Loading and try again. Note that you need to
define the global variables first in global codes then use $GLOBALS[“var”]
to set up the variables.
in Global Codes:
$var = “”; // Define global variable
in Page_Loading:
global $var;
$var = ExecuteScalar(…);
in Global Codes:
function MyFunction() {
$var = ExecuteScalar(…);
return $var;
};
In your header/footer ecc
echo MyFunction()//if string
echo MyFunction()[‘arraykey’]//if array