C
C
cannabioid13372021-07-29 20:02:57
PHP
cannabioid1337, 2021-07-29 20:02:57

How to fix REDBEANPHP array output error?

I have code:

$user = R::find('users', "`email` = ? and `password` = ?", [
       $data['email'],
       $data['password'],
     ]
      );
      echo $user->username;


The result gives an error: Warning: Attempt to read property "username" on array in C:\xampp\htdocs\login.php on line 41
And print_r($user) is -
Array ( [11] => RedBeanPHP\OODBBean Object ( [properties:protected] => Array ( [id] => 11 [username] => kashin1337 [email] => [email protected] [password] => 882b8a5ced0d33ca737165f9d692ad58 [confirmtoken] => 5404BD65-119C-42C4-9A9C-854975005205 [status] => 1 ) [__info:protected] => Array ( [type] => users [sys.id] => id [sys.orig] => Array ( [id] => 11 [username] => kashin1337 [email] => [email protected] [password] => 882b8a5ced0d33ca737165f9d692ad58 [confirmtoken] => 5404BD65-119C-42C4-9A9C-854975005205 [status] => 1 ) [tainted] => [changed] => [changelist] => Array ( ) [model] => [data.bundle] => Array ( ) ) [beanHelper:protected] => RedBeanPHP\BeanHelper\SimpleFacadeBeanHelper Object ( ) [fetchType:protected] => [withSql:protected] => [withParams:protected] => Array ( ) [aliasName:protected] => [via:protected] => [noLoad:protected] => [all:protected] => ) )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Barmunk, 2021-07-29
@cannabioid1337

$user[11]->username

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question