A
A
aaskereia2018-02-02 00:10:23
PHP
aaskereia, 2018-02-02 00:10:23

Why an empty array?

Can you tell me why the array can be empty? those. when you click on the button named save, the record is safely added to the associated table. but when you try to get this $_SESSION['logged_user']->ownPapkyList method - the array is empty. Is there a gross error in this entry? because I'm learning php for a couple of days. It's just that if there was an error somewhere else, the record would not be added, right?

<?php 
    $data = $_POST;
    if (isset($data['save'])) {

      $papka = R::dispense('papki');
      $papka->imya = $data['papkaname'];
      
      $_SESSION['logged_user']->ownPapkyList[] = $papka;	
      R::store($_SESSION['logged_user']);
    } 

    print_r($_SESSION['logged_user']->ownPapkyList);
    
  ?>

decided.
the solution was in the error of writing ownPapkyList over the place of ownPapkiList. because the linked page was called exactly with the ending in i as you can see from the line $papka = R::dispense('papki'); lose everything works

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-02
@vaajnur

this is a gross mistake. see how php array is created

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question