注意:未定义偏移量:4 php


Notice: Undefined offset: 4 php

我在PHP脚本中得到这个错误。我不知道是什么错误…在第一行。

if( $row_Recordset1['stud_mac'] ==$lines[$i]){ // error in this line
            $jumpa="Ya";
            $tarikhHariIni=date("Y-n-j",time()+ 3600*8);
            $masaHariIni=date("Y-n-j H:i:s ",time()+ 3600*8);
            $attID= $row_Recordset1['stud_id']."-".$tarikhHariIni;
            mysql_select_db($database_att, $att);
            $queryAttendRekod = "SELECT * FROM mobats_attendance where stud_id = '$attID'";
            $AttendRekod = mysql_query($queryAttendRekod, $att) or die(mysql_error());
            $row_queryAttendRekod = mysql_fetch_assoc($AttendRekod);
            //echo $row_queryAttendRekod['attID']."<br>";
            if($row_queryAttendRekod['att_id']=="")
             { 
             //echo $masaHariIni;
               $insertData="Insert into mobats_attendance (att_date,stud_id,att_id) values ('$masaHariIni','$row_Recordset1[stud_id]','$attID')";
               $Result1 = mysql_query($insertData, $att) or die(mysql_error());
               echo "Congratulation! You've manage to attend the class. Thank You! <br> Today is ".change2day($tarikhHariIni)." ".change2dmy($tarikhHariIni);
               echo "<br>";
               echo $row_Recordset1['stud_name']." you have attend class on <br> ".substr($masaHariIni,10,19); ?> 
               <?php
             }
    $masuk= $masaHariIni;
    if($masuk=='') {
    $masuk=$row_queryAttendRekod['punchIn']; }
         }
    }

请检查索引是否存在

if( isset($row_Recordset1['stud_mac']) && isset($lines[$i]) && $row_Recordset1['stud_mac']==$lines[$i]){