请我的代码在下面标记此错误,并尝试不时调试它,但我不能。如果有人可以帮助我,我将非常高兴。谢谢
试图在第202行的C:\ wamp64 \ www \ project \ pages \ main \ admin_tools.php中获取非对象的属性“老师”
$teacherSQL = "SELECT teacher FROM teacher_grade_year WHERE session='$current_sess' AND main_teacher='1' AND grade_class_room ='$myroom_id'";//
$dbh_teacher = $dbh->prepare($teacherSQL);
$dbh_teacher->execute();
$fetchObj = $dbh_teacher->fetch(PDO::FETCH_OBJ);
$dbh_teacher = null;
$teacher = $fetchObj->teacher; //This is the line 202 flagging error
$teacher_id= $kas_framework->getValue('staff_id', 'staff', 'staff_id', $teacher);
$teacher_name= '<a href="main?page=view_staff&id='.$teacher_id.'" target="_blank">'.$kas_framework->getValue('staff_lname', 'staff', 'staff_id', $teacher).'
'.$kas_framework->getValue('staff_fname', 'staff', 'staff_id', $teacher).'</a>';//
这是尝试过的方法,但它只选择了在同一行202中指定了特定ID的单个用户
$teacherSQL = "SELECT teacher FROM teacher_grade_year WHERE session='$current_sess' AND main_teacher='1' AND grade_class_room ='$myroom_id'";//
$dbh_teacher = $dbh->prepare($teacherSQL);
$dbh_teacher->execute();
$fetchObj = $dbh_teacher->fetch(PDO::FETCH_OBJ);
$dbh_teacher = null;
$teacher = '2'; //This only show a single teacher with whose ID is equal to '2' and I don't want it that way
$teacher_id= $kas_framework->getValue('staff_id', 'staff', 'staff_id', $teacher);
$teacher_name= '<a href="main?page=view_staff&id='.$teacher_id.'" target="_blank">'.$kas_framework->getValue('staff_lname', 'staff', 'staff_id', $teacher).'
'.$kas_framework->getValue('staff_fname', 'staff', 'staff_id', $teacher).'</a>';//