while($res = mysql_fetch_object($u_result)) {
//print_r($res);
$task_id = $res - > task_id;
//print_r($json['task_info']);
//$task_id = $json['task_info'][0]->task_id;
$sql_g = "SELECT `grade` FROM `t_grades` WHERE `student_id`='$student_id' AND `task_id`= $task_id";
$res_g = mysql_query($sql_g);
if(mysql_num_rows($res_g) > 0) {
$row_g = mysql_fetch_object($res_g);
$res->grade = $row_g['grade'];
}
else {
$res->grade = 'none';
}
//print_r($res);
$json['task_info'][] = $res;
}
echo json_encode($json);
我收到此错误:
Fatal error: Cannot use object of type stdClass as array like this.
这在 localhost 中工作正常,但在服务器上返回错误。什么会导致这个?