-4

I need to display an id number from "kategori_barang" table. When I submitted the code, I get an error message which says "trying to access array offset on the value of type null". Somebody can figure this out? Thanks for the help.

//the title
<h3>Form Edit Kategori</h3>

//syntax for open a controller 
<?php echo form_open('kategori/edit'); ?>
 
//list for display an id number
<input type="text" value="<?php echo $record['kategori_id'];?>" name="id">
<table border="1">
    <tr>
        <td>Nama Kategori</td>
        <td><input type="text" name="kategori" placeholder="kategori" 
                   value="<?php echo $record['nama_kategori'];?>"></td>
    </tr>
    <tr>
        <td colspan="2"><button type="submit" name="submit">Submit</button></td>
    </tr>
</table>
</html>
Prasad Gayan
  • 1,424
  • 17
  • 26

1 Answers1

0

the error means that your $record array has no such key. either use

isset($record['kategori_id']) ? $record['kategori_id'] : 0;

or dump the $record to logs to see what is inside like this

error_log( print_r($record, TRUE) );

and take it from there....it looks like your $record has nothing in it

Tch
  • 1,055
  • 5
  • 11