Note that there are some explanatory texts on larger screens.

plurals
  1. POSimplePie: Fatal error: Call to a member function set_cache_location() on a non-object
    primarykey
    data
    text
    <p>I'm trying to configure the SimplePie RSS parser to cache feeds into a mySQL database, but I keep getting this error messages when I try to load a SimplePie page:</p> <ul> <li>Fatal error: Call to a member function set_cache_location() on a non-object</li> <li>Warning: substr() expects parameter 1 to be string, array given in</li> <li>Warning: PDO::__construct() expects parameter 2 to be string, array given </li> </ul> <p><strong>When I set "port" as "port" I get the following error message:</strong></p> <blockquote> <p>Warning: mysql:// "IT DISPLAYS MY DB USERNAME AND PASSWORD HERE" is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable. in /home/...../SimplePie.php on line 1357</p> </blockquote> <p>Is there anyone familar with SimplePie?</p> <p><strong>EDIT</strong></p> <p>In the code below I've obviously left out my username and password for the mySQL settings. But I just wanted to acknowledge that I "know" I'm supposed to replace those values. Also, I use "3306" as my port number since I'm told that 's the default port number for mysql...and "localhost" for the hostname</p> <p>$feed->set_cache_location('mysql://username:password@localhost:3306/database');</p> <pre><code>&lt;?php include('./base.php'); require_once('./php/autoloader.php'); $feed = new SimplePie(); $feed-&gt;set_cache_location('mysql://username:password@hostname:3306/database'); $rssurl = $_GET['r']; $feedlimit = $_GET['limit']; if (!empty($feedlimit)) { $feedlimit = $_GET['limit']; } else { $feedlimit = 10; } // Set which feed to process. if (!empty($rssurl)) { $feed-&gt;set_feed_url($rssurl); } else $rss_results = mysql_query("SELECT feed_id, feed_url, feed_title, feed_order, feed_page_id FROM user_feeds WHERE ((feed_owner = '" . $_SESSION['UserId'] . "') AND (feed_page_id = '" . $pageid . "')) ORDER BY feed_order ASC LIMIT 1;"); if ($rss_results) { while($row = mysql_fetch_array($rss_results)) { $feed-&gt;set_feed_url($row[feed_url]); } } else { // something went wrong. echo mysql_error(); } $feed-&gt;enable_cache(true); // Run SimplePie. $feed-&gt;init(); // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it). $feed-&gt;handle_content_type(); // Let's begin our XHTML webpage code. The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag. ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Feed Page&lt;/title&gt; &lt;script type="text/javascript" src="./js/jquery-1.3.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="./js/jquery-ui-1.7.1.custom.min.js"&gt;&lt;/script&gt; &lt;link rel='stylesheet' href='./css/styleb.css' type='text/css' media='all' /&gt; &lt;script type="text/javascript"&gt; // When the document is ready set up our sortable with it's inherant function(s) $(document).ready(function() { $("#test-list").sortable({ handle : '.handle', update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.php?"+order); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;div id="rsscontent"&gt; &lt;ul&gt; &lt;?php /* Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop. */ foreach ($feed-&gt;get_items(0,$feedlimit) as $item): $feeditem = $item-&gt;get_feed(); ?&gt; &lt;?php if($_GET["view"] === "headlines") { echo "&lt;li&gt;&lt;h2 class='feed_entry_title'&gt;&lt;a href='"; echo $item-&gt;get_permalink(); echo "'&gt;"; echo $item-&gt;get_title(); echo "&lt;/a&gt;&lt;/h2&gt;"; echo "&lt;hr /&gt;&lt;/li&gt;"; } elseif ($_GET["view"] === "excerpts") { echo "&lt;li&gt;&lt;h2 class='feed_entry_title'&gt;&lt;a href='"; echo $item-&gt;get_permalink(); echo "'&gt;"; echo $item-&gt;get_title(); echo "&lt;/a&gt;&lt;/h2&gt;&lt;div class='feed_entry_content'&gt;"; echo $item-&gt;get_description(); echo "&lt;/div&gt;&lt;hr /&gt;&lt;/li&gt;"; } else { echo "&lt;li&gt;&lt;h2 class='feed_entry_title'&gt;&lt;a href='"; echo $item-&gt;get_permalink(); echo "'&gt;"; echo $item-&gt;get_title(); echo "&lt;/a&gt;&lt;/h2&gt;&lt;div class='feed_entry_content'&gt;"; echo $item-&gt;get_content(); echo "&lt;/div&gt;&lt;hr /&gt;&lt;/li&gt;"; } ?&gt; &lt;?php endforeach; ?&gt; &lt;ul&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload