-2
I have the following code
class Auth {
function getMemberByUsername($username) {
$db_handle = new DBController();
$query = "Select * from members where member_name = ?";
$result = $db_handle->runQuery($query, 's', array($username));
return $result;
}
}
at index I call $user = $auth->getMemberByUsername($username);
and I can use the user variable normally. In the same class I also have the following fuction:
function getMemberNivel($level) {
$db_handle = new DBController();
$query = "Select * from members where nivel = ?";
$result = $db_handle->runQuery($query, 'i', array($level));
return $result;
}
and I call as follows:
$phase = $auth->getMemberNivel($level);
but informs me that the variable $level
there is no, I do not understand what happens, if anyone can help me thank you, because I have spent hours breaking my head with something that may be very simple.
Wow, it was all organized, it was time to publish messed up everything
– PeeWee
The OS uses markdown, in the question text field there is an explanation of how to use the main. And where this variable came from
$level
?– Costamilam
I’m kind of a beginner yet, don’t I get it, what do you mean by so and markdown?? and the variable $level is declared inside the function, as well as the $username.
– PeeWee
I’m researching markdown
– PeeWee
OS = Stackoverflow (site of questions and answers that we are using). Markdown = markup language (https://answall.com/help/formatting). Which line is the error?
– Costamilam
NESTA: $Phase = $auth->getMemberNivel($level); it does not recognize the level variable, but it is there in the function.... isn’t it so ? I followed the example of the others, because in the same file you have other functions, I just copied the function getMemberByUsername and changed the variable name and select
– PeeWee
Your error is programming logic, when you call a function by passing arguments, these must exist, for example,
$level = 5; $phase = $auth->getMemberNivel($level);
if you do not declare the variable before passing as argument of a function will give error, because it is passing something that does not exist (was not declared)– Costamilam