Session is not started in global code yet so you cannot use session unless you start it yourself, and your code is actually executing the SQL every page, not for a PHP session (as you suggested by storing it in $_SESSION variable). If the record count of mprce changes between pages, keep your code. Othewise, you may use:
if (!isset($_SESSION[“Count20”])) $_SESSION[“Count20”] = ExecuteScalar(“SELECT COUNT(*) FROM mprce”);
ExecuteScalar actually works in Global Code, and at the start i did put it in the MenuItem_Adding server event but i have more than one query like this and it slows down the application so bad because i think it runs the query on every menu item. I am adding this for counting the number of records in these tables and putting it like number on menu.
i did add session_start(); in the global code and this fixed the problem. is this ok to have here? or does it affect anything?
what is strange is that my code worked perfectly before the new build update.