What's wrong with my code?
$stmt = $db->prepare("SELECT * FROM allfriend WHERE friendOf = ?");
$stmt->bind_param('s', $userId);
if($stmt->execute()){
$result = $stmt->get_result();
while ($obj = $result->fetch_object()) {
$result[] = $obj;
}
echo json_encode($result);
}