ok i have a mysqli function that draws a users stat from a database. the datbase is set up as
username attack defense strength
xxxx 10 10 10
the problem i am running into is the function is returning nothing, the page is blank. my connection to the database present and session username is stored so i can figure out why its not working.
config.php
<?php
$dbhost = 'xxx';
$dbuser = 'xxx';
$dbpass = 'xxx';
$dbname = 'xxx';
$dberror1 = 'could not connect to database';
$dberror2 = 'could not find selected table';
?>
stat.php
<?php
function getLevel($stat) {
require_once 'includes/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$stmt = $mysqli->prepare("SELECT ? FROM players WHERE username = ?");
if($stmt) {
$stmt->bind_param('ss', $stat, $_SESSION['username']);
if($stmt->execute()) {
$stmt->bind_result($result);
$stmt->fetch();
}
}
return $result;
}
?>
and the file im using to test displaying the function
<?php
include 'includes/login-check.php';
include 'includes/config.php';
include 'includes/stat.php';
echo getLevel('attack');
?>