I'm trying to query users Level but I'm not able to return an int
. I have no idea why because when I echo the result it gives is i.e "1"
function lvl_chcek($username)
{
$db = new mysqli('localhost', 'root', 'root', 'idoctor_db');
$lvl = $db->query('
SELECT Level
FROM users
WHERE Login = "'.$username.'"
');
echo $lvl->fetch_object()->Level;
return $lvl->fetch_object()->Level;
}
I also tried this but I get NULL
function lvl_chcek($username)
{
$db = new mysqli('localhost', 'root', 'root', 'idoctor_db');
$query = $db->query('
SELECT Level
FROM users
WHERE Login = "'.$username.'"
');
$result = mysql_query($query);
$array = mysql_fetch_assoc($result);
$lvl = $array['Level'];
echo $lvl;
return $lvl;
}