Hi! I guess I have a little understanding about functions and how they work.. Idea is to get "user's group" from database, but I don't want to write the code evey time when I need it so I decided to put it in function.
function get_role()
{
$user_id = $_SESSION['login_ok'];
$res = mysql_query('SELECT role FROM users WHERE id = "'.$user_id.'"') or mysql_error();
$row = mysql_fetch_array($res);
$role = $row['role'];
}
and then when I need it
get_role();
What I need is $role variable which I will use in if() to grant access to smth. But when I do so, it shows that $role is Undefined variable (when I do that checking with if).
Sorry for probably dumb questions but what am I doing wrong?