Welcome Guest, Not a member yet? Register   Sign In
Undefined offset for high array indexes?
#1

[eluser]Mutsop[/eluser]
Hi,

I'm getting some odd error with my code. So I'm actually retrieving data from a db, in a foreach loop (for each group). I store that data in an array (without index specification).

Here is my code:
Code:
$groups = array(266,273,272,271,255,268,258,269,256,275,1044,270,278,257,989,274);
        
        foreach($groups as $group) {
            $con = Doctrine_Manager::getInstance()->connection();
            $st = $con->execute("SELECT invGroups.groupID, invGroups.groupName, invTypes.typeName AS skillName,
                invTypes.description, invTypes.typeID
                FROM invTypes, invGroups
                WHERE invTypes.groupID = invGroups.groupID
                AND invTypes.groupID = ". $group ."
                ORDER BY groupName, skillName;");

            $result = $st->fetchAll();
            $skills_info[] = $result;
        }

Now in the view I use the following:
Code:
<?php
   $count = 0;
   foreach($skillsinfo as $skillinfo){
?>
   <h2><img src="&lt;?php echo site_url('assets/images/groups/'. $skillinfo[$count]['groupID'] .'.png'); ?&gt;" />&lt;?php echo $skillinfo[$count]['groupName']; ?&gt;</h2>
&lt;!-- some more code --&gt;
&lt;?php
    $count += 1;
    }
?&gt;

Now all groups (from the group array) work, except for groupid 1044. That one gives me a "Undefined offset: 10" ... 10 being the index of the array (so if I change the 1044 place, the offset number changes place too.

Now, I did a test and all indexes below the 1043 work.

Any ideas?




Theme © iAndrew 2016 - Forum software by © MyBB