• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Error org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject

ACoder

Lurker
Here's my php


<?php

if ($_SERVER['REQUEST_METHOD']=='POST') {

$username = $_POST['username'];
$password = $_POST['password'];

require_once 'connect.php';

$sql = "SELECT * FROM students WHERE username='$username' AND password='$password'";

$response = mysqli_query($conn, $sql);

$result = array();
$result['login'] = array();


if(mysqli_num_rows($response) > 0){
$rs = mysqli_fetch_array($response);

$index['name'] = $rs[1];
$index['username'] = $rs[3];

array_push($result['login'], $index);

$result['success'] = "1";
$result['message'] = "success";

header('Content-Type: application/json');
echo json_encode($result);
mysqli_close($conn);

}else{
$result['success'] = "0";
$result['message'] = "error";
echo json_encode($result);

mysqli_close($conn);
}

}

?>
 
Back
Top Bottom