Welcome Guest, Not a member yet? Register   Sign In
"Message: Undefined index:" Problem
#1

[eluser]ChazUK[/eluser]
Hi,

I'm taking data from a database, which I'm then putting into a multidimensional array dynamically.

The problem is that CI keeps giving me these errors
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: #####

Filename: controllers/#####.php

Line Number: ##
I know that to avoid this I should check if the array is set before I try to manipulate the array instance, but I thought this would just add extra time to the script.

Also, when I loop through the SQL results (there are over 27,000) the foreach loop doesn't finish.
Is this an occasion when using more SQL queries is better than letting PHP do the work?

Thanks
#2

[eluser]pistolPete[/eluser]
Please post your controller code.
#3

[eluser]ChazUK[/eluser]
Code:
foreach($query->result() as $row)
{
    $units = $row->stat_units / 60;
    $statistics[$row->show_group][$row->tos_group][$row->stat_date] = $units;
    $statistics[$row->show_group][$row->tos_group]['TOTAL'] += $units;
}




Theme © iAndrew 2016 - Forum software by © MyBB