1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

magpieRSS help. Cannot use object of type MagpieRSS as array :(

Discussion in 'Content Management' started by karate_kid007, Dec 4, 2008.

  1. #1
    Hi All,

    I am having trouble with displaying multiple rss feeds on my webpage, i am using an array to get the values/address of the rss feeds from with in my database and i am trying to display the first item from each feed but for some reason i am getting a fatal error

    Fatal error: Cannot use object of type MagpieRSS as array in /customers/kernow-connect.com/kernow-connect.com/httpd.www/affiliate/entertainment(test3).php on line 144


    it works on another page using just 1 feed and displaying ten items

    here is the code for my other page which works
        print "<div class='TabbedPanelsContent'>";
    	
    	if ($feedID == '1' and $rssIndividualNR == ""){
    	print "No Data To Display Please Check Back Soon";
    	}
    		elseif ($feedID == '1' and $rssIndividualNR <> ""){
    		
    		$xml=simplexml_load_file($rssIndividualNR);
    
    		$productNo = count($xml);
    			if ( $productNo < 10 ){
    			$max = $productNo;
    			}
    				else {
            		$max = 10;
    				}
            
    		$i = 1; 
    				
    		foreach($xml as $feed){
           
            	if ($i <= $max){
                	echo "<div class='topitems'>";
                	echo "<div class='topitemsinner'>";
                	echo "<a href='{$feed->deepLink}' target='_blank'><img src='{$feed->imageURL}' alt='{$feed->productname}' border='0' hspace='5' /></a>";
                	echo "<a href='{$feed->deepLink}' target='_blank'><div class='producttitle'>{$feed->productname}</a></div><br><br>";
                	echo "<div class='productdescription'>{$feed->description}</div><p>";
                	//echo "<div class='productdescription'>Availability: {$feed2->availability}</div>";
                	echo "</div>";
                	echo "</div>";
                	$i++;// increase counter by 1
    				}
            } 
          }  
    		
    		elseif ($feedID == '2' and $rssIndividualNR == ""){
    		print "No Data To Display Please Check Back Soon";
    		}
    		
    			elseif ($feedID == '2' and $rssIndividualNR <> ""){
    			//RSS NEWS FEED SECTION
    			$rss = fetch_rss($rssIndividualNR);
    			$loop_count = 1;
    	
    				foreach ($rss->items as $item){ 
    
    				$href = $item['link'];  
    				$title = $item['title'];  
    				$desc = $item['description'];  
    				$ref_date = $item['pubdate'];
    				$content = $item['atom_content'];
    	
    				echo "<div class='topitems'>";
       				echo "<div class='topitemsinner'>"; 
    				print $title;
    				print "<br>";
    				print $content;
    				print $desc;
    				echo "</div>";
    				echo "</div>";	
    	}
    }
    	
        print "</div>";
    
    PHP:
    this above code is repeated 3 times for 3 tab pannels on the same page

    and this is the code that doesnt work
    	print "<div class='recommends'>";
    		
    	if ($rss[0] == ""){
    	print "No Information Currently Available Please Check Back Soon";
    	}
    	elseif ($rss[0] <> "" and $feed[0] == '2'){
    	$rss = fetch_rss($rss[0]);
    		
    		$loop_count = 0;
    		for ($r = 0; $r <= $loop_count; $r++) {
    		
    		foreach ($rss->items as $item){ 
    			if ($r <= $loop_count){
    			$href = $item['link'];  
    			$title = $item['title'];  
    			$desc = $item['description'];  
    			$ref_date = $item['pubdate'];
    			$content = $item['atom_content'];
    	 
    			print "<br>";
    			print $content;
    			$r++;
    	}
    }
    	}
    	}
    	
    	elseif ($rss[0] <> "" and $feed[0] == '1'){
    		$xml=simplexml_load_file($rss[0]);
            $max = 1;
    			for ($m = 0; $m < $max; $m++) {
    		 	// if counter is greater than max, break loop
    				foreach($xml as $feed2){
            		// create counter on first loop
            
            			if ($m < $max){
               			echo "<a href='{$feed2->deepLink}' target='_blank'><div class='producttitle'>{$feed2->productname}</a></div><br>";
               			echo "<a href='{$feed2->deepLink}' target='_blank'><img src='{$feed2->imageURL}' alt='{$feed2->productname}' border='0' hspace='5' /></a>";
    		   			$m++;
    		   			}
               		}
          		} 
    	} 
    	
    	print "</div>";
    PHP:
    this is also copied three times but the only real difference that i can spot is the first one only one feed is dislayed at a time and are contained within tab pannels and the second all three are displayed at the same time with in div containers.

    so it seems odd as to why one works and the other doesnt, is there any obvious differences between the two codes that may prevent the second from displaying properly.

    any help would be ace :)

    Many Thanks
    Luke
     
    karate_kid007, Dec 4, 2008 IP
  2. karate_kid007

    karate_kid007 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its ok now thanks I've sorted it out some how :D
    cheers
     
    karate_kid007, Dec 4, 2008 IP