dbopen return the PDO object
which passed to dbupdate and is undefined at that point, WHY?
include(“db.php”);
include(“config.php”);
$pdo="";
if ($_SESSION[“onlinestat”] == “0”)
{
$pdo = dbopen();
$_SESSION[“onlinestat”] =“6”;
}
else
{
This is not a scope problem, it is a conditional execution problem. Depending on the result of the conditional comparison, either the code inside the if(){…} block is executed or the code inside the else{…} block is executed, not both. The connection code needs to be unconditionally executed at a common point in the code before it is needed. I recommend that the db.php code make the connection without needing any additional statements.
You should use ‘require’ for things your code must have, Include/require are not functions. The () around the path/filename do nothing and should be removed.