What I'm trying to do is to create a connection to a MySQL database using a random function that returns (or I wish it would) a mysqli_result. Unfortunately it doesn't work. It returns boolean instead. The function:
function itsName()
{
    $host="localhost";
    $user="root";
    $password="";
    $database="";
    return mysqli_connect($host,$user,$password,$database);
}
And when I try to create a connection and use it in a query:
$con = itsName();
$query = mysqli_query($con, "ANY QUERY");
$fetch = mysqli_fetch_assoc($query);
Any normal query doesn't respond with an error, but when I try to, for example, fetch it to an assoc array it gives this error:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\site\site.php on line X
It's obvious that itsName function returns boolean instead of mysqli_result.
My question is, is it even possible to achieve what I'm trying to do here? To make my function return a mysqli_result instead of boolean. If so, please help me out with how the code should look like.
And please don't ask why am I even trying to do something like this. Just an experiment.
 
     
    