Question

I'm pretty new to PHP and was doing fine until I hit this brick wall. Any help would be greatly appreciated.

Actually, it was a simple miscommunication issue with my partner... he changed the directory structure without me knowing which resulted in this issue. This question may be considered closed. Thank you for all your help.

I have a class user() in which I created this get_articles() public function:

public function get_articles($obj_user){
        try
        {
            $loc_dbo = $obj_user->connect();

            $query = "CALL VIEW_MEMBER_ARTICLES(:in_var1)";
            $stmt = $loc_dbo->prepare($query);

            $stmt->bindParam(':in_var1',$obj_user->id, PDO::PARAM_INT);

            $result = $stmt->execute();

            if($result)
            {
                $arrArticles = array();
                $index=0; //INDEX OF ROW IN ARRAY
                while ($row = $stmt->fetch (PDO::FETCH_ASSOC))
                {
                    //ADDING DATA TO A TWO-DIMENSIONAL ARRAY
                    //NAMED COLUMNS
                    $arrArticles[$index] = array();
                    $arrArticles[$index]['mem_user_name']=$row['mem_user_name'];
                    $arrArticles[$index]['article_post_date']=$row['article_post_date'];
                    $arrArticles[$index]['lvl_short_desc']=$row['lvl_short_desc'];
                    $arrArticles[$index]['article_subject']=$row['article_subject'];
                    $arrArticles[$index]['article_body']=$row['article_body'];
                    $arrArticles[$index]['pic_URL']=$row['pic_URL'];

                    $index++; //INCREMENT ROW INDEX COUNTER
                }
            $stmt->closeCursor(); //releases the bdd connection for another query.
            return $arrArticles; //RETURNS THE ARRAY CONTAINING ARTICLES
            }
            else
            {
                return "Query Failed!";
            }
        }

        catch(PDOException $e) {

            return $e->getMessage();
        }
    }
}

From a page in which I have included my user class file, I'm calling this function like so:

            $arr_posts = $p_user->get_articles($p_user);

                for ($row = 0; $row < count($arr_posts); $row++)
                {
                    for ($col = 0; $col < 6; $col++) 
                    {
                    echo "<tr class=\"".active."\">";
                    echo "<td>\"".$row."\"</td>";
                    echo "<td>".$arr_posts[$row]['article_post_date']."</td>";
                    echo "<td>".$arr_art[$row]['article_subject']."</td>";
                    echo "<td>"."2"."</td>";
                    echo "</tr>";
                    }
            }

$p_user is declared at the top of the page, as a new user(). I just can't understand why I'm getting an error saying the method is undefined.

Was it helpful?

Solution

Folders were simply misplaced by an associate. Closed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top