{"id":585,"date":"2022-08-30T15:03:48","date_gmt":"2022-08-30T15:03:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/undefined-error-in-codeigniter-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:03:48","modified_gmt":"2022-08-30T15:03:48","slug":"undefined-error-in-codeigniter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/undefined-error-in-codeigniter-collection-of-common-programming-errors\/","title":{"rendered":"Undefined error in codeigniter-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m building a file uploader that gets IPTC data from the image and inserts it into a db but I keep getting this error:<\/p>\n<pre><code>&gt; A PHP Error was encountered\n&gt; \n&gt; Severity: Notice\n&gt; \n&gt; Message: Undefined index: 2#120\n&gt; \n&gt; Filename: controllers\/upload.php\n&gt; \n&gt; Line Number: 63\n<\/code><\/pre>\n<p>Here&#8217;s the line from the controller:<\/p>\n<pre><code>$iptc_description = $iptc[\"2#120\"];\n<\/code><\/pre>\n<p>The script works perfectly as it&#8217;s supposed to, but it keeps throwing up this error and I can&#8217;t figure out why.<\/p>\n<ol>\n<li>\n<p>Replace that line with (your using the variable before its set):<\/p>\n<pre><code>$iptc_description = (isset($iptc[\"2#120\"]))?$iptc[\"2#120\"]:null;\n<\/code><\/pre>\n<p>Or if you don&#8217;t like one-liners:<\/p>\n<pre><code>$iptc_description = null;\nif (isset($iptc[\"2#120\"])) {\n    $iptc_description = $iptc[\"2#120\"];\n}\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:06:16. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m building a file uploader that gets IPTC data from the image and inserts it into a db but I keep getting this error: &gt; A PHP Error was encountered &gt; &gt; Severity: Notice &gt; &gt; Message: Undefined index: 2#120 &gt; &gt; Filename: controllers\/upload.php &gt; &gt; Line Number: 63 Here&#8217;s the line from the controller: [&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-585","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/585","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=585"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/585\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}