Hello guys, i'm trying to show the full name of my user what is logged in. I am new to writing in oop. Im getting a undifined index fullname error. Can anyone help me?

  /*** for showing the username or fullname ***/
  public function get_fullname($userid)
  {
         $stmt = $this->db->prepare("SELECT fullname FROM users WHERE   userid = $userid");  
        $stmt->execute();

    /* Fetch all of the remaining rows in the result set */
    $user_data = $stmt->fetchAll();
    echo $user_data['fullname'];


  }

Recommended Answers

All 2 Replies

Try :

echo $user_data[0]['fullname'];

since fetchAll returns a set of all the rows (only one in your case).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.