0
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);
我收到此錯誤:JSON工作在本地主機但不是服務器?
Fatal error: Cannot use object of type stdClass as array like this.
這個工作在本地主機正常,但在服務器上返回一個錯誤。什麼會造成這種情況?
本地主機vs服務器的pvp版本是什麼? – 2013-03-09 15:10:22
'$ res-> grade = $ row_g ['grade'];'應該是'$ res-> grade = $ row_g-> grade;' – BenM 2013-03-09 15:10:53
其工作正常......非常感謝你 – Gireesh 2013-03-09 15:13:59