php - Fatal error: Call to a member function connect() on null -
trying include function "overlay" config.php other php pages.
index.php:
<?php include("./config/config.php"); over_lay(); ?> //// html code //// the error is:
fatal error: call 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 partly mysqli requests //// <?php $mysqli->close(); } ?> and mysql.php:
<?php function connect() { $mysqli = new mysqli("localhost","root","","database_name"); $mysqli->query("set names utf8"); return $mysqli; } ?> i'm testing on openserver , of course have database.
call function inside over_lay
include("./config/mysql.php"); function over_lay() { $mysqli = connect(); ?> //// html code partly mysqli requests //// <?php $mysqli->close(); } update changed
$mysqli->connect();
to
$mysqli = connect();
Comments
Post a Comment