{"id":816,"date":"2022-08-30T15:07:39","date_gmt":"2022-08-30T15:07:39","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/php-codeigniter-error-call-to-undefined-method-ci_db_mysql_driverresult-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:39","modified_gmt":"2022-08-30T15:07:39","slug":"php-codeigniter-error-call-to-undefined-method-ci_db_mysql_driverresult-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/php-codeigniter-error-call-to-undefined-method-ci_db_mysql_driverresult-collection-of-common-programming-errors\/","title":{"rendered":"PHP Codeigniter error: call to undefined method ci_db_mysql_driver::result()-Collection of common programming errors"},"content":{"rendered":"<p>I was trying to create an xml response using codeigniter. The following error gets thrown when i run the code.<\/p>\n<p><em>This page contains the following errors:<\/em><\/p>\n<pre><code> 0)\n            {\n                foreach ($query-&gt;result() as $row){\n                    echo ''.$row-&gt;title.'';\n                }\n            }\n        }\n        echo '';\n    }\n}\n?&gt;\n<\/code><\/pre>\n<ol>\n<li>\n<p>Your code here is wrong:<\/p>\n<pre><code>  $this-&gt;db-&gt;where('email_id', $email);\n            $this-&gt;db-&gt;limit(1);\n            $query = $this-&gt;db-&gt;from('lp_user_master');\n            $this-&gt;get();\n<\/code><\/pre>\n<p>Should be, instead:<\/p>\n<pre><code>  $this-&gt;db-&gt;where('email_id', $email);\n  $this-&gt;db-&gt;from('lp_user_master'); \n  $this-&gt;db-&gt;limit(1);\n  $query = $this-&gt;db-&gt;get();\n<\/code><\/pre>\n<p>Now you can call <code>$query-&gt;result()<\/code>, because the result resource is there after you actually get the table results<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:47:14. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I was trying to create an xml response using codeigniter. The following error gets thrown when i run the code. This page contains the following errors: 0) { foreach ($query-&gt;result() as $row){ echo &#8221;.$row-&gt;title.&#8221;; } } } echo &#8221;; } } ?&gt; Your code here is wrong: $this-&gt;db-&gt;where(&#8217;email_id&#8217;, $email); $this-&gt;db-&gt;limit(1); $query = $this-&gt;db-&gt;from(&#8216;lp_user_master&#8217;); $this-&gt;get(); Should [&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-816","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/816","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=816"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/816\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}