Howdy all; I picked up the PHP Anthology books (both Vols.)
around my birthday in early July. I never even picked them
up once I saw it was all in OOP (@ the time, didn't know OOP).
Fast forwarding, it finally just *clicked*-- the whole OOP thing
thanks to a link someone gave me.
Now, I used the class just fine to query just once, find
how many records, etc. ~ basicly all the examples.
However, some pages I'm using more than one query
and this is where my troubles begin.
Fatal error: Call to a member function query() on a non-object in E:\xampp\xampp\htdocs\actual\Last Entry\blog.php on line 64Nothing overtly fancy; anyways, any idea how to get around this?Code:<?php session_start(); // Set the page title $title = "Last Entry.com - Home"; // Set the Description Meta Data $dmeta = "Description Meta Data"; // Set the Keyword Meta Data $kmeta = "Keyword Meta Data"; // Require the class fil require_once('rf/class.php'); // Require the News Page System require_once('rf/nps.php'); // Require the header file require_once('rf/head.php'); $blog = $_GET['blog']; if (isset($blog)) { // Connect to MySQL $db = & new MySQL($host,$dbUser,$dbPass,$dbName); // Set up the query... $gdnps = "SELECT id, author, title, msg, email, DATE_FORMAT(date, '%h:%i - %m.%d.%y'), blog"; $gdnps .= " FROM gdnps WHERE blog='$blog' ORDER BY id DESC LIMIT $from, $max_results"; // Perform said query $result = $db->query($gdnps); while ($row = $result->fetch()) { $id = $row['id']; $entryauthor = $row['author']; $entrytitle = $row['title']; $entrytext = $row['msg']; $email = $row['email']; $date = $row['date']; $cresults = mysql_query("SELECT * FROM comments WHERE news_id='$id' "); $num_rows = mysql_num_rows($cresults); // Build the output right here echo "<div class=\"title\">$entrytitle</div>"; echo "<div class=\"normal\">[ Posted by $entryauthor @ $date | "; echo "<a href=\"comments.php?id=$id\" class=\"doc\">Read</a> / "; echo "<a href=\"reply.php?id=$id\" class=\"doc\">Reply</a> / $num_rows Replies ] </div>"; } } else { // send a query to the mySQL database $sql = "SELECT id, blog FROM blog ORDER BY blog ASC"; $result2 = $db->query($sql); while ($row2 = $result2->fetch()) { $id2 = $row2['id']; $blog2 = $row2['blog']; echo "<div class=\"title\">Current List of Blogs</div>"; echo "<div class=\"normal\">$blog2 -> <a href=\"blog.php?blog=$blog2\" class=\"doc\">Click here to view</a> <br /></div>"; } } require_once('rf/np.php'); require_once('rf/foot.php'); ?>
I'm still new to OOP, so I can't figure this one out![]()



Thanks! Did the trick

Bookmarks