Trying to include function "overlay" from config.php into other php pages.
Index.php:
<?php include("./config/config.php");
over_lay(); ?>
//// html code ////
The error is:
Fatal error: Call to a member function connect() on null in ...\config\config.php on line 182
Part of config.php:
include("./config/mysql.php");
function over_lay()
{
$mysqli->connect();
?>
//// html code with partly mysqli requests ////
<?php
$mysqli->close();
}
?>
And finally mysql.php:
<?php
function connect()
{
$mysqli = new mysqli("localhost","root","","database_name");
$mysqli->query("SET NAMES utf8");
return $mysqli;
}
?>
I'm testing this on OpenServer and of course I do have the database.