gaza165 Posted January 21, 2010 Share Posted January 21, 2010 Below I have my Blog Class that controls everything to do with my blog. I want to be able to parse the `home_body` using the NBBC Code Parser. However, when I try to run the Parse method on my `home_body` row, I get this error! Call to a member function Parse() on a non-object Can anyone help me and tell me what I am doing wrong? <?php include("nbbc.php"); $bbcode = new BBCode; class Blog { private $dbLink; var $title, $home_body, $main_body, $blog_created, $posted_by, $blog_thumb; function __construct() { $this->dbLink = mysql_connect('localhost', 'root', ''); mysql_select_db('test'); } function Retrieve_Blogs() { $this->dbLink = mysql_query("SELECT * FROM `blog` ORDER BY `blog_created` DESC"); while($row = mysql_fetch_array($this->dbLink)) { echo $bbcode->Parse($row['home_body']); } } function Show_Blog($blog_title) { $this->dbLink = mysql_query("SELECT * FROM `blog` WHERE `blog_title` = '$blog_title'"); while($this->rows = mysql_fetch_array($this->dbLink)) { print $this->rows['blog_title']; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/189308-call-to-a-member-function-parse-on-a-non-object/ Share on other sites More sharing options...
JAY6390 Posted January 21, 2010 Share Posted January 21, 2010 Put global $bbcode; just after the function Retrieve_Blogs() { Quote Link to comment https://forums.phpfreaks.com/topic/189308-call-to-a-member-function-parse-on-a-non-object/#findComment-999377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.