I'm making a login script which fetches data from two tables. I understand that this error occurs when the statement returns FALSE AKA a boolean, but why is it returning false??? I made a function which works up to a point
    function loginall($username, $password)
{
    $db_host="localhost";
    $db_username="root";
    $db_password="";
    $db_name="name";
    $con=mysqli_connect($db_host, $db_username,$db_password, $db_name);
    $mysqli = new mysqli("$db_host","$db_username","$db_password", "$db_name");
    $qry = "SELECT username, password, level, active FROM businesses  WHERE username=? AND password=? 
    UNION SELECT username, password, level, active FROM employees WHERE username=? AND password=?";
    $stmt = $mysqli->prepare($qry);
    $stmt->bind_param("ssss", $u,$p,$uu,$pp);
    $u = $username;
    $p = $password;
    $uu = $username;
    $pp = $password;
    $stmt->execute();
    $result = $stmt->get_result();
    while($row = $result->fetch_array(MYSQLI_ASSOC))
    {
        return $row;
    } 
}
it works great until I try fetching more columns from the tables, or even trying to SELECT * from the tables. I read through other similar questions and found codes to get the error to appear, but no luck. Thank you! 
 
     
    