problem displaying all of an array
Posted: Mon Jan 24, 2011 11:30 am
I have an array that I have created (contains 4 sections in total - 1 database, 1 query, 4 lines in the result):
[MySQL06] => Array
(
[0] => Array
(
[id] => 14
[running] => completed
[dt] => 2011-01-24 15:54:23
)
[1] => Array
(
[id] => 15
[running] => completed
[dt] => 2011-01-24 15:54:24
)
But when I try to refer to them I get an error:
Fatal error: Cannot use [] for reading in C:\wamp\www\ts\DBresult.php on line 28
How can I refer to the 4 sections accurately?
If I take the [] out I get errors like:
Notice: Undefined index: id in C:\wamp\www\ts\DBresult.php on line 30
[MySQL06] => Array
(
[0] => Array
(
[id] => 14
[running] => completed
[dt] => 2011-01-24 15:54:23
)
[1] => Array
(
[id] => 15
[running] => completed
[dt] => 2011-01-24 15:54:24
)
But when I try to refer to them I get an error:
Code: Select all
foreach($instance2[] as $DB2) {
$id = $DB2['id'];
$running = $DB2['running'];
$dt = $DB2['dt'];
};
How can I refer to the 4 sections accurately?
If I take the [] out I get errors like:
Notice: Undefined index: id in C:\wamp\www\ts\DBresult.php on line 30