Code:
$query = "SELECT* FROM {$this->vartotojai_lentele} WHERE username='{$data['username']}'";
$result = array();
$result = mysql::select($query);
$ulvl = $result["userlevel"];
echo $ulvl;
var_dump($result); die();
Error and dump:
Notice: Undefined index: userlevel in Notice: Undefined index: userlevel in *.php on line 114
array(1) { [0]=> array(4) { ["userid"]=> string(2) "18" ["username"]=> string(5) "admin" ["password"]=> string(32) "******" ["userlevel"]=> string(1) "3" } }
I'm trying to asign $result["userlevel"] to another variable, but I get this error. I'm new in PHP and I've been searching how to fix this problem, but I couldn't find anything. What's the problem here? Seems like my $result array isn't empty.
FIXED: "$ulvl = $result[0]["userlevel"];. 0 is the first row, userlevel the column."
Thank you everyone.