试图获取非对象的属性 - PHP

时间:2017-03-26 03:10:29

标签: php mysql sql

所以我正在尝试获取与用户输入的教师名字和姓氏相对应的teacher_id,但是当我尝试获取teacher_id时,它会输出{{1} }。有没有人有任何想法?

PHP

Trying to get property of non-object

>

1 个答案:

答案 0 :(得分:0)

更改此行,您正在检查查询是否正常,但您尚未检查它是否有任何结果。

$sqlmon="SELECT *, SUM(TIMEDIFF(t.timeouthour, t.timeinhour)) 
AS Duration FROM timesheets t 
WHERE employee_id='$session_myemployeeid' 
AND timeinyear='$currentyear' 
AND timeinmonth='$currentmonth' 
AND timeinday='Monday' ";
$resultmon=mysqli_query($db,$sqlmon);

to(如果您有结果数据,此行检查您是否有任何结果数据$ row否则为null)

if($teacher_check) {
        $row = $teacher_check->fetch_object();