samedi 24 novembre 2018

I get the Error of Trying to get property of non-object [duplicate]

This question already has an answer here:

I'm trying to show data. This is the code I used to get the users from the database.

              $queryuser = "SELECT id, email, firstname, lastname, address, city, country  FROM users WHERE role = 'client'";
              $resultuser = $connection->query($queryuser);
              if ($resultuser->num_rows > 0) {

                while($rowuser = $resultuser->fetch_assoc()) {
                  $id_user = $rowuser['id'];
                  $firstname = $rowuser['firstname'];
                  $lasttname = $rowuser['lastname'];
                  $email = $rowuser['email'];
                  $city = $rowuser['city'];
                  $country = $rowuser['country'];
                  $address = $rowuser['address'];
          ?>

Then I get this error: Trying to get property of non-object, for the (if statement line). I've looked on few of the same cases as mine but I couldn't manage to fix it.

Aucun commentaire:

Enregistrer un commentaire