【问题标题】:Notice: Undefined offset: 4 php [duplicate]注意:未定义的偏移量:4 php [重复]
【发布时间】:2013-05-24 15:32:20
【问题描述】:

我在我的 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']; }

         }
    }

【问题讨论】:

  • 您的 lines 数组包含少于 5 个条目,因此没有条目号 4 ,-)
  • 它没有给出我需要的东西..不同的错误..

标签: php


【解决方案1】:

请检查索引是否存在

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

【讨论】:

  • 它确实有帮助..thanx 兄弟..
  • 如果上面的代码可以帮助你请投票给答案
猜你喜欢
  • 2020-01-22
  • 2023-03-27
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多