Here is what my script basically looks like:
[CODE]<?php
require_once( PATH . ‘/includes/ADP_Posts.class.php’ );
if ( have_posts() ) {
if ( is_single() ) {
$sb_posts = new ADP_Posts( ‘type=rel&postID=’ . $post->ID . ‘&numPosts=3&period=week’ );
$sb_postsTitle = ‘Related’;
if ( ! $sb_posts->hasPosts() ) {
$sb_posts = new ADP_Posts( ‘type=ran&numPosts=3’ );
$sb_postsTitle = ‘More News’;
}
} else {
$sb_posts = new ADP_Posts( ‘type=ran&numPosts=3’ );
$sb_postsTitle = ‘More News’;
}
}
?>
<!– do some html stuff –>
<?php if ( $sb_posts->hasPosts() ) {
// do some php stuff with the $sb_posts object
} ?>
<!– continue html stuff –>
When $sb_posts->hasPosts() is called the second time, the script runs as expected, but I keep getting:
[14-Oct-2008 14:00:18] PHP Fatal error: Call to a member function hasPosts() on a non-object in /thescript.php on line 35
in my error log, reported twice at 2 second intervals every time the script is called and only when the method is called again on line 35
I just can’t figure this one out, I’ve tried stting the $sb_posts variable to null and using the unset( $sb_posts ) but I don’t know
if it matters all $sb_posts->hasPosts() does is return a 1 or 0 value based on the length of an array