PHP - Std::Class error

Asked

Viewed 59 times

1

I have the following code:

case 'operator-autentication':
    global $decoded;
    $array = array();
    $user = $decoded->user;
    $pass = $decoded->pass;
    $opr = new opr_func();
    $arrResp = $opr->loginFunc($user, $pass);
    if(empty($arrResp) == true) {
        $array[] = array('id' => '0');
    } else {
        foreach($opr->loginOperator($decoded->code, $decoded->pass) as $ip) {
            $array[] = array('id' => $ip->id, 'name' => $ip->name, 'clientId' => $ip->clientId);
        }
    }        
    echo json_encode($array);
    break;

When I test a send of parameters it happens the error:


Notice: Undefined Property: stdClass::$user in /Applications/XAMPP/xamppfiles/htdocs/bullGreenPanel/Assets/php/client/Appcollect.php online 94

If you don’t use the var $decoded->code (which is what comes in the app) works, what would be reason and solution ?

Ps: at the beginning of the code has :

$postdata = file_get_contents("php://input");
$decoded = json_decode($postdata);
  • After global $decoded put a print_r of this variable. See the contents of it and post so we can understand what it contains.

  • Apparently $decoded does not have the attribute user.

  • Really, my fault, does not have the attribute user... pfvr put an answer to give as ok

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.