{"id":7192,"date":"2014-05-27T09:07:50","date_gmt":"2014-05-27T09:07:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/fatal-error-using-this-when-not-in-object-context-collection-of-common-programming-errors\/"},"modified":"2014-05-27T09:07:50","modified_gmt":"2014-05-27T09:07:50","slug":"fatal-error-using-this-when-not-in-object-context-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/27\/fatal-error-using-this-when-not-in-object-context-collection-of-common-programming-errors\/","title":{"rendered":"Fatal error: Using $this when not in object context-Collection of common programming errors"},"content":{"rendered":"<p>I am using smarty templates for pinnaclecart to pull post data from wordpress database so the website can show the blog posts. I fixed IF unexpected error but now it is back to $this. I m stuck \ud83d\ude41<\/p>\n<p>public_blog.php<\/p>\n<p><strong>EDIT back<\/strong><\/p>\n<pre><code>    function getPosts()\n{\n        $query= $this-&gt;db-&gt;query(\"\n        SELECT * from wp_posts where post_status='publish' AND post_type = 'post'\n        \");\n\n        $posts = array();\n        if ($this-&gt;db-&gt;moveNext($query, MYSQL_ASSOC))\n        {\n                 $posts[] = $this-&gt;db-&gt;col;\n\n        }\nreturn $posts;\n\n}\n$posts = getPosts();\nview()-&gt;assign(\"body\", \"templates\/pages\/site\/blog.html\");\n<\/code><\/pre>\n<p>Could not figure IF error part<\/p>\n<p>The help will be appreciated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am using smarty templates for pinnaclecart to pull post data from wordpress database so the website can show the blog posts. I fixed IF unexpected error but now it is back to $this. I m stuck \ud83d\ude41 public_blog.php EDIT back function getPosts() { $query= $this-&gt;db-&gt;query(&#8221; SELECT * from wp_posts where post_status=&#8217;publish&#8217; AND post_type = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7192","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7192"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7192\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}