PHP를 사용하여 mysql 데이터베이스에 연결하고 다음 함수를 사용하여 데이터베이스에서 여러 행을 검색 한 다음 배열에 추가하고 다시 보내십시오. 내부 서버 오류 또는 500x 오류 메시지가 나타납니다. 나는이 코드가 무엇이 잘못되었는지 확신하지 못한다. 나는 그것을 알아 내려고 노력했지만 그것을 얻을 수는 없다.새로운 mysqli 쿼리로 여러 행을 가져 오는 중?
public function getUnreadMessages($uname){
$stmt = $this->conn->prepare("SELECT msgid, title, fromuname FROM messages WHERE touname = ? and status = ?");
$status = 'unread';
$stmt->bind_param("ss", $uname, $status);
if ($stmt->execute()) {
$stmt->bind_result($col1, $col2, $col3);
$stmt->store_result();
$resp = array();
while($stmt->fetch()){
$row = array();
array_push($row, $col1, $col2, $col3);
array_push($resp, $row);
}
$msg = array('msgid' => $msgid,'title' => $title,'fromuname' => $fromuname);
$stmt->close();
return $msg;
} else {
$stmt->close();
return NULL;
}
}
어떻게해야합니까?
$app->get('/inbox', 'authenticate', function() use ($app){
ob_start("ob_gzhandler");
global $global_user_name;
$db = new DbHandler();
$resp = $db->getUnreadMessages($global_user_name);
$msgs = array();
$msgs['status'] = 'success';
$msgs['version'] = 0.1;
array_push($msgs, $resp);
$app->response()->header('Content-Type', 'application/json');
echo json_encode($msgs);
exit;
});
이것은 서버 측과 관련이 있습니다. 코드 끝까지 도달하지 못했습니다 .... 실제 URL을 사용하고 있는지 여부를 확인하십시오. –
크롬 개발자 도구를 사용하여 요청 및 응답 헤더를 모니터링하고 있습니다. 요청은 서버에서 보내고받습니다. 서버는 500 개의 메시지로 연결을 닫습니다. 사이트에 오류가있는 경우이 문제에 여러 번 직면했습니다. 오류 로깅에 관해서는, 나는 디버그를 가능하게했다. 때로는 일부 구문 분석 오류 또는 사소한 오류가 표시됩니다. 그들이하지 않은 다른 시간 –
서버는 URL을 통한 로그인을 지원합니까? 나는 URL을 통해 전달할 자격 증명을 의미합니까? –