Undefined error in codeigniter-Collection of common programming errors
I’m building a file uploader that gets IPTC data from the image and inserts it into a db but I keep getting this error:
> A PHP Error was encountered
>
> Severity: Notice
>
> Message: Undefined index: 2#120
>
> Filename: controllers/upload.php
>
> Line Number: 63
Here’s the line from the controller:
$iptc_description = $iptc["2#120"];
The script works perfectly as it’s supposed to, but it keeps throwing up this error and I can’t figure out why.
-
Replace that line with (your using the variable before its set):
$iptc_description = (isset($iptc["2#120"]))?$iptc["2#120"]:null;
Or if you don’t like one-liners:
$iptc_description = null; if (isset($iptc["2#120"])) { $iptc_description = $iptc["2#120"]; }
Originally posted 2013-11-09 21:06:16.