Page 1 of 1
Undefined Array Key
Posted: Sun Jun 04, 2023 8:44 am
by amsire2
// Row Inserted event
function Row_Inserted($rsold, &$rsnew)
{
//Log("Row Inserted");
$merit = ExecuteScalar("SELECT Peringkat_Aktiviti FROM permohonan WHERE ID_Permohonan = ".$rsnew["ID_Permohonan"]."");
if ($merit = 8){
Execute("UPDATE kehadiran SET Markah = 0.75 WHERE ID = ".$rsnew["ID"]."");
}
}
I create a code above and when I want to insert the record, error come out like this
Warning: Undefined array key "ID_Permohonan" in C:\xampp8\htdocs\eaktiviti\models\Kehadiran.php on line 1507
permohonan is my Master table and kehadiran is my details table
Re: Undefined Array Key
Posted: Sun Jun 04, 2023 10:43 am
by arbei
The error means there is no $rsnew["ID_Permohonan"]
in $rsnew
. You better check what are available first, for example, by var_dump($rsnew);die();
or Log(json_encode($rsnew))
(check the data in the log file).
Re: Undefined Array Key
Posted: Sun Jun 04, 2023 12:53 pm
by mobhar
Perhaps it is ID instead of ID_Permohonan field name.
In addition, double check this part:
if ($merit = 8){
That code should be:
if ($merit == 8) {
Re: Undefined Array Key
Posted: Sun Jun 04, 2023 2:35 pm
by amsire2
mobhar wrote:
Perhaps it is ID instead of ID_Permohonan field name.
In addition, double check this part:
if ($merit = 8){
That code should be:
if ($merit == 8) {
I'll check