I'm currently making a system with with phpMyAdmin and I'm coming across a common error. I tried to type in an auto increment system which provides a unique id to an attribute in increasing order.
<?php $query = "select * from penilaian order by idpenilaian desc limit 1";
$result = mysqli_query($sambungan, $query);
$row = mysqli_fetch_array($result);
$lastid = $row['idpenilaian'];
if($lastid == ' '){
$idpenilaian = "N10";
}
else{
$idpenilaian = substr($lastid,1);
$idpenilaian = intval($idpenilaian);
$idpenilaian = "N" . ($idpenilaian + 1);
}
?>
But I'm getting the error message
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\pertandingan_inovasi\penilaian_insert.php
I'm guessing it's something related to the attribute 'idpenilaian' being a primary key and is not null.
Here's the output image error_array-offset
Can someone please help me with this? Thanks!