Jump to content

Can't find the source of Resource id #4


wee493

Recommended Posts

I'm getting a Resource id #4 with the following code and can't find the source of the issue. The following PHP receives a list of posts from a database and echo's them. Everything echos fine and the Resource id #4 error only shows up once, so I don't think it has anything to do with the while loops echoing the posts.

 

$error = '';
$ppp = '5';
$reg_num = ($page - 1) * $ppp;

if ($user != 'guest' && isset($_SESSION['user'])){
$has_feeds = "SELECT feed FROM subscriptions WHERE username = '$user' AND type = 'blog'";

if (mysql_num_rows($has_feeds) == '0'){ // If user has no feeds //
		$error = '<p align="center"><font color="red" size="4"><ul><strong>You are not subscribed to any feeds</strong></ul></font><font color="green" size="4"><strong>You can edit your feeds <a href="manage_feeds.php">here</a>.</strong></font>';
} else {

	$user_feeds = array(); // define an empty array
	while ($r = mysql_fetch_array($has_feeds)){
		$user_feeds[] = $r['feed']; // add an element to the array
} // end while //

// Get posts that user has hidden //
if ($user != 'guest'){
	$sql = mysql_query("SELECT * FROM user_hide_posts WHERE user = '$user'");
		if (mysql_num_rows($sql) != '0'){
			$exempt_p = array(); // define an empty array
				while ($r = mysql_fetch_array($sql)){
					$exempt_p[] = $r['pid'];
				}
		} else {
			$exempt_p = array(1, 2, 3);
		}

	$qry = mysql_query("SELECT post_per_page FROM userinfo WHERE username = '$user'"); // Get users Post Per Page Setting //
	$ppp = mysql_result($qry, 0);
}
// end hidden posts //	

	$user_feed = array(); // define an empty array
	foreach ($user_feeds as $f){
				$user_feed[] = $f; // add an element to the array
	} // End foreach //

	$sql = mysql_query("SELECT * FROM posts WHERE feed_id IN(" . implode(',',$user_feed) . ") AND status = 'publish' AND id NOT IN (" . implode(',',$exempt_p) . ") ORDER BY `posts`.`date` DESC LIMIT $reg_num, $ppp"); // Set getting post SQL statement //

	$sqlf = mysql_query("SELECT id FROM posts WHERE feed_id IN(" . implode(',',$user_feed) . ") AND status = 'publish' AND id NOT IN (" . implode(',',$exempt_p) . ") ORDER BY `posts`.`date` DESC LIMIT $reg_num, 1"); // SQL to see if it is first post //

}
} else {
$sql = mysql_query("SELECT * FROM posts WHERE feed_id > '0' AND status = 'publish' ORDER BY `posts`.`date` DESC LIMIT $reg_num, $ppp"); // Set getting post SQL statement //
$sqlf = mysql_query("SELECT id FROM posts WHERE feed_id > '0' AND status = 'publish' ORDER BY `posts`.`date` DESC LIMIT $reg_num, 1"); // SQL to see if it is first post //
}
echo $sql;
while ($r = mysql_fetch_array($sql)){
$title = $r['title'];
$id = $r['id'];
$content = $r['data'];
$link = $r['permalink'];
$feed_id = $r['feed_id'];
// begin shares //
$share_digg = $r['share_digg'];
$share_delicious = $r['share_delicious'];
$share_reddit = $r['share_reddit'];
$share_facebook = $r['share_facebook'];
$share_twitter = $r['share_twitter'];
// end shares //
$date = Timesince($r['date']);
	$first1 = @mysql_result($sqlf, 0);
		if ($first1 == $id){
			$first1 = 'first ';
		} else {
			$first1 = ''; 
		}
// Get link to website homepage & favicon //
$query = mysql_query("SELECT feed_domain FROM sc_feeds WHERE feed_id = '$feed_id'");
$post_domain = @mysql_result($query, 0);
$query2 = mysql_query("SELECT feed_icon FROM sc_feeds WHERE feed_id = '$feed_id'");
$favicon = @mysql_result($query2, 0);
		include('../functions/remove_unwanted_post_content.php');
?>


			<div class="<?PHP echo $first1; ?> article" id="<?PHP echo $id; ?>" style="display: block">
                
			<h3><a href="<?PHP echo $link; ?>" onmousedown="javascript: MyAjaxRequest('main', './functions/count_visit.php?state=visit&feed=<?PHP echo $feed_id; ?>&post=<?PHP echo $id; ?>&type=blog&user=<?PHP echo $user; ?>');return true"><?PHP echo $title; ?></a></h3>

            	<p class="meta"><a href="http://<?PHP echo $post_domain; ?>" onmousedown="javascript: MyAjaxRequest('main', './functions/count_visit.php?state=visit&feed=<?PHP echo $feed_id; ?>&post=<?PHP echo $id; ?>&type=external&user=<?PHP echo $user; ?>&dest=http://<?PHP echo $post_domain; ?>');return true">
                
			<?PHP
			echo " <img src=\"$favicon\" style=\"border: 0px; vertical-align: text-bottom; padding:0px; background: none; margin: 0px; width:16px; height: 16px;\" /> ";
			echo ucfirst($post_domain); ?></a> | <?PHP echo $date; ?> ago
                
                <?PHP if ($user != 'guest'){ ?>
                <span class="hide_post"><a href="javascript: MyAjaxRequest('mn', './functions/hide_post.php?state=hide&post=<?PHP echo $id; ?>'); toggle(<?PHP echo $id; ?>);" id="hide_post"><img src="img/delete.png" alt="Hide Post" /></a></span>
                <?PHP } ?>
                </p>
			<?PHP echo $content; ?>
                <!-- Share Links -->
                    <div class="share_post">
                        <!-- <span class="right"><a href="#" onclick="javascript: MyAjaxRequest('email', './functions/share.php?state=email&post=<?PHP //echo $id; ?>'); return false;"><img src="img/email-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span> -->
                        <span class="right"><a href="<?PHP echo $share_delicious; ?>"><img src="img/delicious-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span>
                        <span class="right"><a href="<?PHP echo $share_digg; ?>"><img src="img/digg-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span>
                        <span class="right"><a href="<?PHP echo $share_facebook; ?>"><img src="img/facebook-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span>
                        <span class="right"><a href="<?PHP echo $share_reddit; ?>"><img src="img/reddit-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span>
                        <span class="right"><a href="<?PHP echo $share_twitter; ?>"><img src="img/twitter-48x48.png" style="border: 0px; padding:0px; margin: 0px; width:35px; height:35px;" /></a></span>
                        <div id="email"></div>
                    </div>
                <!-- End Share Links -->
			</div>
<?PHP } // End While // ?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.