Welcome Guest, Not a member yet? Register   Sign In
Undefined index
#1

[eluser]Unknown[/eluser]
I have wrote this:

<?php
if(count($daftar_dokumen)) {
foreach ($daftar_dokumen as $indeks => $list) {
$i = $indeks +1 + $on_page;
echo "<tr height='30' class='rowJadwal'><td class = 'rowJadwalTepi' width='5'> </td>";
echo "<td align = 'center'>".$i."</td>" ;
echo "<td>".anchor("dokumen/detailDokumen/".$list['kode_dokumen'],$list['judul_dokumen'],array('class'=>'linkAllPengumuman'))."</td>";
echo "<td>".$list['nama_kategori_dokumen']."</td>";
echo "<td>".$list['unit_kerja_stis']."</td>";
echo "<td class = 'rowJadwalTepi' width='5'> </td>";
echo "<tr>";
}
}
?&gt;

And then the warning like this:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: kode_dokumen

Filename: dokumen/daftarDokumen.php

Line Number: 19


The code i have wrote was implemented to another function and it works but why it can't be at this function?
#2

[eluser]vile[/eluser]
[quote author="Axelline" date="1279712795"]I have wrote this:

Code:
&lt;?php
        if(count($daftar_dokumen)) {
            foreach ($daftar_dokumen as $indeks => $list) {
                $i = $indeks +1 + $on_page;
                echo "<tr  height='30' class='rowJadwal'><td class = 'rowJadwalTepi' width='5'> </td>";
                echo "<td align = 'center'>".$i."</td>" ;
                echo "<td>".anchor("dokumen/detailDokumen/".$list['kode_dokumen'],$list['judul_dokumen'],array('class'=>'linkAllPengumuman'))."</td>";
                echo "<td>".$list['nama_kategori_dokumen']."</td>";
                echo "<td>".$list['unit_kerja_stis']."</td>";
                echo "<td class = 'rowJadwalTepi' width='5'> </td>";
                echo "<tr>";
            }
        }
        ?&gt;



And then the warning like this:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: kode_dokumen

Filename: dokumen/daftarDokumen.php

Line Number: 19


The code i have wrote was implemented to another function and it works but why it can't be at this function?[/quote]

check $list array if it contains $list['kode_dokumen'] index..
#3

[eluser]KingSkippus[/eluser]
Try inserting the following debug line just to test $list at the top of your loop and see if it contains what you expect it to contain:

Code:
echo '<pre>'.htmlentities(var_export($list, TRUE)).'</pre>';

If it does not have array elements for kode_documen, judul_dokumen, name_kategori_documen, etc., then you will receive the error. If there is a chance that the kode_documen element may be missing but you still need the loop to run anyway with the array keys that do exist, you can do something like this:

Code:
$kode_document = array_key_exists('kode_documen', $list) ? $list['kode_documen'] : '';
echo “<td>”.anchor(“dokumen/detailDokumen/”.$kode_dokumen,
    $list[‘judul_dokumen’],array(‘class’=>‘linkAllPengumuman’)).”</td>”;




Theme © iAndrew 2016 - Forum software by © MyBB