php - Fatal error: Call to a function on a non-object in -


I am printing information from a table (tblgroups) and after that I am using a group of members (TWG Group_member) avatars (Tblgroup_member)

When I try to get the Gram_id (I'm imprinting from the group) function Getmembers) This is telling me that I have a non-object ( $ memberinfo = $ Group- & gt; Getmembers ($ group ["group_id"]); ). But I declare the $ group = new group (); ?

It is saying that the mistake is on this line: $ memberinfo = $ group-> Getmembers ($ Group ["group_id"]);

PHP

  $ group = new group (); Foreign exchange ($ group $ group) {resonant "& lt; p class = 'groupname' & gt; & lt; a href = 'group.php? Group_id =' $ group ['group_id']. '' & Gt; ". $ Group ['group_name']" & lt; / A & gt; & Lt; / P & gt; "; echo $ group ['group_id']; $ memberinfo = $ group- & gt; Getmembers ($ group [" group_id "]); / * Foreach ($ member $ $ as member) { Echo "& lt; P & gt; ". $ Member ['avatar']" & lt;     

function gatemember (if necessary)

  public function Getmembers ($ group_id) {$ db = New db (); $ Select = "SELECT g.group_id, m.user_id, u.avatar FROM ((tblgroups in G INNER tblgroup_member m g.group__id = m.group__id) INNER tblusers u include u.user_id = M.user_id) WHERE G Group_id = ". $ Group_id" "$ result = $ db -> Conn -> query ($ selection); $ Result_array = array (); while ($ line = mysqli_fetch_array ( $ Result)) {$ result_array [] = $ line;} return $ result_array;}  

< P> Your first thing

  $ group = new group ();  

and then a loop

  foreach ($ group $ group) {/ code>  

you are inside the loop

  

here $ group- & gt; its This does not mean that the object is more than written in array data or other words from foreach and $ group is no longer an object

Solution

Changes

$ Group = New Group ();

to

  $ group_obj = new group ();  

then

  $ memberinfo = $ group-> Getmembers ($ group ["group_id"]);  

to

  $ memberinfo = $ group_obj-> Getmembers ($ group ["group_id"]);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -